READSEQ

Top  Previous  Next

 

The READSEQ statement reads the next field from a directory file record previously opened for sequential access.

 

 

Format

 

READSEQ var FROM file.var {ON ERROR statement(s)}

{THEN statement(s)}

{ELSE statement(s)}

 

where

 

varis the variable to receive the data read from the file.

 

file.varis the file variable associated with the record by a previous OPENSEQ statement.

 

statement(s)are statement(s) to be executed depending on the outcome of the READSEQ.

 

At least one of the THEN and ELSE clauses must be present.

 

The next field is read into var. If successful, the THEN clause is executed and the STATUS() function would return zero.

 

If there are no further fields to be read, the ELSE clause is executed and the STATUS() function would return ER$RNF (record not found).

 

If a fatal error occurs, the ON ERROR clause is executed. The  STATUS() function can be used to establish the cause of the error. If no ON ERROR clause is present, a fatal error causes an abort.

 

The  FILEINFO() function can be used with key FL$LINE to determine the field number that will be read by the next READSEQ.

 

 

Example

 

LOOP

  READSEQ REC FROM STOCK.LIST ELSE EXIT

  GOSUB PROCESS.STOCK.ITEM

REPEAT

 

This program fragment reads fields from the record open for sequential access via the STOCK.LIST file variable and calls the PROCESS.STOCK.ITEM subroutine for each field. The loop terminates when the ELSE clause is executed when all fields have been processed.

 

 

See also:

CLOSESEQ, NOBUF, OPENSEQ, READBLK, READCSV, SEEK, WEOFSEQ, WRITEBLK, WRITECSV, WRITESEQ, WRITESEQF