file i/o
three main alternatives:
- write to (create) and read from a MSG file via I/O redirection
- use :PRINT and I/O redirection to read file 1 record at a time
- use entry points and I/O redirection
-
why not use INPUT in WHILE to read a flat file, e.g.:
- while not eof do input varname < filename … endwhile
MSG file works because each read is destructive, so next INPUT reads next record
Notes:
- INPUT <flat_file in the WHILE loop fails because the CI opens the redirected file for each iteration in the loop. Thus, an open is done for each record in the file. Not only is this expensive, it also means that the file’s record pointer (current record) is reset to the beginning of the file each time INPUT is executed. Therefore, INPUT from a flat file in a WHILE loop always reads (and re-reads!) the first record of the file.