Question about DCL CHAR VARYING



IBM's cross-platform compiler PL/I for MVS, VM & VSE, OS/390 and Enterprise PL/I for z/OS

Question about DCL CHAR VARYING

Postby marshall25 » Wed Jul 10, 2013 9:23 am

hi all,

i have a test souce as
PLIPGM: PROC OPTIONS(MAIN);                   
DCL 01 A,                                     
       02 A1  CHAR(02) INIT('T~'),           
       02 A2  CHAR(10) VAR INIT('ABC'),       
       02 A3  CHAR(02) INIT('~T');           
DCL INFILE   FILE RECORD INPUT;               
DCL REPORT   FILE RECORD OUTPUT,             
    SYSPRINT FILE STREAM OUTPUT;             
      OPEN FILE (INFILE)   INPUT;             
      OPEN FILE (REPORT)   OUTPUT,           
           FILE (SYSPRINT) OUTPUT;           
      PUT SKIP(2) EDIT ('ABC:',A,':')(A,A,A);
      WRITE FILE (REPORT) FROM (A);           
      CLOSE FILE (INFILE),                   
            FILE (REPORT),                   
            FILE (SYSPRINT);                 
END PLIPGM;                                   


when i checked output file, the writen record is
T~..ABC.......~T

when i cheked sysprint, displaied as
ABC:T~ABC~T:

The value of A2 is different between in write file and sysprint, why? if i want to write the record as
ABC:T~ABC~T:
, how can i code?
marshall25
 
Posts: 26
Joined: Mon Jun 20, 2011 9:14 am
Has thanked: 0 time
Been thanked: 0 time

Re: Question about DCL CHAR VARYING

Postby NicC » Wed Jul 10, 2013 2:06 pm

Why have A2 as varying? If you need it varying then it should go at the end of the structure. A3 is always going to start at 13.

BTW: you should not declare/open/close SYSPRINT as it is open long before your program is invoked by the PL/1 environment and you could lose information by doing so.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Question about DCL CHAR VARYING

Postby marshall25 » Wed Jul 10, 2013 2:25 pm

thanks your quick reply, Nicc
marshall25
 
Posts: 26
Joined: Mon Jun 20, 2011 9:14 am
Has thanked: 0 time
Been thanked: 0 time


Return to PL/I

 


  • Related topics
    Replies
    Views
    Last post