The ureadline() function reads data from a previously opened file on the host system.
A file on the host system is represented as an unformatted string of bytes without internal delimiters or markers. READ and WRITE commands provide sequential access to files by advancing a pointer within the file. Subsequent READ or WRITE commands advance this internal pointer from the current position in the file. The user may specify the exact location within a file to be read by positioning the file pointer at the preferred location before executing the command.
UREADLINE var FROM FileHandle {UNTIL delimiter} THEN statement(s) ELSE statement(s)
For example, the following statement generates the behavior as shown in the table.
UREADLINE var FROM filehandle UNTIL ';' THEN/ELSE clause
Host File Contents | var | THEN/ELSE | UERROR( ) |
---|---|---|---|
EOF | "" | ELSE | 38 |
";EOF" |
"" "" |
THEN ELSE |
0 38 |
";;EOF" |
"" "" "" |
THEN THEN ELSE |
0 0 38 |
"ABCEOF" |
"ABC" "" |
THEN ELSE |
3 38 |
"ABC;EOF" |
"ABC" "" |
THEN ELSE |
3 38 |
"ABC;;EOF" |
"ABC" "" "" |
THEN THEN ELSE |
3 0 38 |
"ABC;XYZEOF" |
"ABC" "XYZ" "" |
THEN THEN ELSE |
3 3 38 |
"ABC;XYZ;;EOF" |
ABC" "XYZ" "" |
THEN THEN ELSE |
3 3 38 |
";ABC;;XYZ;;EOF" |
"" "ABC" "" "XYZ" "" "" |
THEN THEN THEN THEN THEN ELSE |
0 3 0 3 0 38 |
The following example prints the first line (delimited by a line-feed) of the \books\chap5.txt file. A null string is returned if the file pointer is positioned at the end of the file.
FILENAME="c:\books\chap5.txt" LF = CHAR(10) UOPEN FILENAME FOR READ TO FILEDES ELSE PRINT "Unable to open ":FILENAME STOP END UREADLINE VAR1 FROM FILEDES UNTIL LF ELSE GOTO EOJ: END PRINT VAR1