UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

READSEQ Syntax READSEQ var FROM seq.file.var {THEN statements [END] | ELSE statements [END]} Description The UniBasic READSEQ command reads the next record from a sequential file and assigns the data read to a variable. Note: Before you use READSEQ, you must open the file by using the OSOPEN or OPENSEQ command. If the file is a named pipe, you cannot use READSEQ to read it. You must use the OSBREAD command. Each read from the sequential file searches for a line feed character [CHAR(10)] to determine the end of the record. READSEQ maintains a pointer to the current position in the file (where the last record terminated). Parameters The following table describes each parameter of the syntax. Parameter Description 1-636 UniBasic Commands Reference var Specifies a variable to which to assign the record. READSEQ Parameters

Parameter Description FROM seq.file.var Specifies a sequential file from which to read the record. seq.file.var must be a sequential file opened by using an OPENSEQ or OSOPEN statement. THEN statements END THEN executes if the read is successful. END is required to terminate multiline THEN statements. ELSE statements END ELSE executes if the read is not successful or the record does not exist. END is required to terminate multiline ELSE statements. Example In the following example, the program statement reads the next record in the file PORT.FILE and assigns it to the variable TAX.REC: READSEQ TAX.REC FROM PORT.FILE ELSE STOP "Can’t READSEQ TAX.REC" Related Commands UniBasic READSEQ Parameters (continued) CLOSESEQ, OPENSEQ, OSBREAD, OSBWRITE, OSCLOSE, OSDELETE, OSOPEN, WRITESEQ, WRITESEQF READSEQ 1-637

Parameter Description<br />

FROM seq.file.var Specifies a sequential file from which to read the record.<br />

seq.file.var must be a sequential file opened by using an<br />

OPENSEQ or OSOPEN statement.<br />

THEN statements END THEN executes if the read is successful. END is required to<br />

terminate multiline THEN statements.<br />

ELSE statements END ELSE executes if the read is not successful or the record does not<br />

exist. END is required to terminate multiline ELSE statements.<br />

Example<br />

In the following example, the program statement reads the next record in the file<br />

PORT.FILE and assigns it to the variable TAX.REC:<br />

READSEQ TAX.REC FROM PORT.FILE ELSE STOP "Can’t READSEQ TAX.REC"<br />

Related <strong>Commands</strong><br />

<strong>UniBasic</strong><br />

READSEQ Parameters (continued)<br />

CLOSESEQ, OPENSEQ, OSBREAD, OSBWRITE, OSCLOSE, OSDELETE,<br />

OSOPEN, WRITESEQ, WRITESEQF<br />

READSEQ 1-637

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!