Q: How can I read in variable length delimited fields from a sequential file? An example format would look like this:
field1|field2|field3|...
field11|field22|field33|...
field111|field222|field333|...
A: Instead of reading a record into individual fields, read the entire record
into one field and then use the SQR unstring command to seperate the
delimited fields.
---------------------------- Example code begins here -------------------------
!
! This report shows how to read in a sequential file with variable length
! delimited fields.
begin-report
open 'test.dat' as 1 for-reading record=80:vary
while 1
read 1 into $record:80
if #end-file
break
end-if
unstring $record by '|' into $field1 $field2 $field3 ...
show $field1 ' ' $field2 ' ' $field3 ...
end-while
close 1
end-report
---------------------------- Example code ends here ---------------------------