WRITEBLK

WRITEBLK

Top  Previous  Next

 

The WRITEBLK statement writes data at the current file position in a record previously opened using OPENSEQ.

 

 

Format

 

WRITEBLK var {ENCODING name} TO file.var

{ON ERROR statement(s)}

{THEN statement(s)}

{ELSE statement(s)}

 

where

 

varis the name of a variable holding the data to be written.

 

file.varis the file variable associated with the file.

 

statement(s)are statements to be executed depending on the outcome of the WRITEBLK operation.

 

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

 

The THEN clause is executed if the WRITEBLK is successful.

 

The ELSE clause is executed if the WRITEBLK fails. The STATUS() function will indicate the cause of the error.

 

The ON ERROR clause is executed for serious fault conditions such as errors in a file's internal control structures. The STATUS() function will return an error number. If no ON ERROR clause is present, an abort would occur.

 

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

 

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

 

 

Example

 

WRITEBLK VAR TO SEQ.F ELSE STOP 'Write error'

 

This program fragment writes data to a file previously opened to file variable SEQ.F.

 

 

See also:

CLOSESEQ, CREATE, NOBUF, OPENSEQ, READBLK, READCSV, READSEQ, WRITECSV, WEOFSEQ, WRITESEQ, WRITESEQF