OPEN DATASET FNAME FOR INPUT IN BINARY MODE.
READ DATASET FNAME INTO TEXT2 LENGTH LENG.
leng 能够判断 text2 的长度
DATA FNAME(60) VALUE 'myfile'.
DATA: TEXT1(4) VALUE '1234 ',
TEXT2(8) VALUE '12345678',
TEXT3(2),
LENG TYPE I.
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE.
TRANSFER: TEXT1 TO FNAME,
TEXT2 TO FNAME.
CLOSE DATASET FNAME.
OPEN DATASET FNAME FOR INPUT IN TEXT MODE.
DO 2 TIMES.
READ DATASET FNAME INTO TEXT3 LENGTH LENG.
WRITE: / TEXT3, LENG.
ENDDO.
CLOSE DATASET FNAME.
The output appears as follows:
12 4
12 8
This example writes the strings TEXT1 and TEXT2 to the file "myfile" in text mode. They are then read into the string TEXT3 (length 2). The amount of memory occupied by the lines is read into the field LENG.