OSBWRITE

Writes an OS file to an file opened.

 

COMMAND SYNTAX

OSBWRITE Variable ON |TO FileVar AT ByteExpr {ON ERROR Statements}

 

SYNTAX ELEMENTS

Variable Specifies the variable to contain the data from the read.
FileVar Specifies the file descriptor of the file opened (via OSOPEN).
AT ByteExpr Specifies a location in the file from which to begin writing data. If ByteExpr is 0, the write begins at the beginning of the file.
ON ERROR Statements Conditional jBC statements to execute if the OSBWRITE statement fails with a fatal error because the file is not open, an I/O error occurs, or jBASE cannot find the file. If you do not specify the ON ERROR clause and a fatal error occurs, the program terminates.

 

NOTES

The jBC OSBWRITE command writes an expression to a OS file starting at a specified byte location. OSBWRITE immediately writes a file segment out to the UNIX or Windows NT file.

jBC begins writing to the file at the offset specified by ByteExpr.  After successful execution of OSBWRITE, the file pointer remains at the next byte after the data is written.

You do not have to specify a length expression because the number of bytes in Variable is written to the file.

Reminder

You must first open the file by using the OSOPEN command. jBC uses the ASCII 0 character (CHAR(0)) as a string-end delimiter. Therefore, ASCII 0 cannot be used in any string variable within jBC. If jBC reads a string that contains CHAR(0) characters by using OSBREAD, those characters are converted to CHAR(128). OSBWRITE converts CHAR(128) back to CHAR(0) when writing a block of characters.

 

EXAMPLES

OSBWRITE Rec TO MyFile AT 50

 

Related Commands

OSOPEN, OSCLOSE, OSBREAD, OSREAD, OSWRITE, OSDELETE


jBC