WRITESEQ

WRITESEQ, WRITESEQF

Top  Previous  Next

 

The WRITESEQ statement writes a string array to a directory file record previously opened for sequential access. WRITESEQF is identical except that it force writes the data to disk.

 

 

Format

 

WRITESEQ var {ENCODING name} TO file.var {ON ERROR statement(s)}

{THEN statement(s)}

{ELSE statement(s)}

 

where

 

varis the variable containing the data to be written.

 

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 WRITESEQ.

 

The keyword TO may be replaced by ON. At least one of the THEN and ELSE clauses must be present.

 

 

The optional ENCODING clause sets the character encoding to be used, overriding any encoding set in the VOC F-type record or when the file was opened. A null string as the encoding name is equivalent to not having the ENCODING clause at all. To disable the default encoding, the encoding name should be specified as "NULL".

 

The data in var is written to the record at the current file position, overwriting any data already present. The THEN clause is executed if the write is successful.

 

The ELSE clause is executed if the WRITESEQ operation fails. On ECS mode systems, STATUS() value ER$ECS.DATA will be returned if data containing ECS characters is written to a directory file with no encoding. The write will have completed but only the low order byte of each character will have been written.

 

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 written by the next WRITESEQ. This information is not valid if the SEEK, READBLK or WRITEBLK statements have been used.

 

If the record was opened with the SHARED option of OPENSEQ, the data will be appended to any existing record content.

 

The WRITESEQF statement is identical to WRITESEQ except that execution of the next QMBasic statement does not occur until the data has been written to disk. With WRITESEQ, the data may still be in internal buffers.

 

 

Example

 

WRITESEQ REC TO STOCK.LIST ELSE ABORT "Write error"

 

This statement writes the data in REC to the record open for sequential access via the STOCK.LIST file variable.

 

 

See also:

CLOSESEQ, CREATE, NOBUF, OPENSEQ, READBLK, READCSV, READSEQ, WEOFSEQ, WRITEBLK, WRITECSV