WRITEBLK statement
Syntax
WRITEBLK expression ON file.variable{THEN statements [ELSE statements] | ELSE statements}
Description
Use the WRITEBLK statement to write a block of data to a file opened for sequential processing. Each WRITEBLK statement writes the value of expression starting at the current position in the file. The current position is incremented to beyond the last byte written. WRITEBLK does not add a newline at the end of the data.
file.variable specifies a file opened for sequential processing.
The value of expression is written to the file, and the THEN statements are executed. If no THEN statements are specified, program execution continues with the next statement. If the file cannot be accessed or does not exist, the ELSE statements are executed; any THEN statements are ignored.
If either expression or file.variable evaluates to the null value, the WRITEBLK statement fails and the program terminates with a run-time error message.
If NLS is enabled, the data written is mapped using the appropriate output file map.
Example
OPENSEQ 'FILE.E','RECORD4' TO FILE ELSE ABORT
WEOFSEQ FILE
DATA1='ONE'
DATA2='TWO'
*
WRITEBLK DATA1 ON FILE ELSE ABORT
WRITEBLK DATA2 ON FILE ELSE ABORT
* These two lines write two items to RECORD4 in
FILE.E without
* inserting a newline between them.
WEOFSEQ FILE
SEEK FILE,0,0 ELSE STOP
READSEQ A FROM FILE THEN PRINT A
* This reads and prints the line just written to the
file.
This is the program output:
ONETWO