Flexible NC programming
1.20 READ: Read lines in the file
Job planning
Programming Manual, 03/2006 Edition, 6FC5398-2BP10-1BA0
1-65
result
Array of type STRING, where the read text is stored
(call-by-reference parameter with a length of 255).
If the number of lines specified in the parameter "number" is smaller than the array length of
"result", the other array elements are not altered.
Termination of a line by means of the control characters "LF" (Line Feed) or "CR LF"
(Carriage Return Line Feed) is not stored in the target variables "result". Read lines are cut
off, if the line is longer than the string length of the target variable "result". An error message
is not output.
Note
Binary files cannot be read in.
The error message error=4: Wrong type of file is output. The following types of file are not
readable: _BIN, _EXE, _OBJ, _LIB, _BOT, _TRC, _ACC, _CYC, _NCK.
Examples
N10 DEF INT ERROR ;error variable
N20 STRING[255] RESULT[5] ;result variable
...
N30 READ(ERROR, "TESTFILE", 1, 5,
RESULT)
;file name without domain and file
;identifier
...
N30 READ(ERROR, "TESTFILE_MPF", 1, 5,
RESULT)
;file name without domain and with
;file identifier
...
N30 READ(ERROR,"_N_TESTFILE_MPF",1,5,
RESULT)
;file name with domain and file
;identifier
...
N30 READ(ERROR,"/_N_CST_DIR/_N_TESTFILE
_MPF", 1, 5 RESULT)
;file name with domain and file
;identifier and path specification
^...
N40 IF ERROR <>0 ;error evaluation
N50 MSG("ERROR "<<ERROR<<"
WITH READ COMMAND")
N60 M0
N70 ENDIF
...