OSBREAD

Reads an OS file from a file opened.

 

COMMAND SYNTAX

OSBREAD Variable FROM FileVar AT ByteExpr LENGTH LengthExpr {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 reading data. If ByteExpr is 0, the read begins at the beginning of the file.
LENGTH LengthExpr Specifies a length of data to read from the file, starting at ByteExprLengthExpr cannot be longer than the maximum string length determined by your system configuration.
ON ERROR Statements Conditional jBC statements to execute if a fatal error occurs (if the file is not open, or if the file is a read-only file). If you do not specify the ON ERROR clause, the program terminates under such fatal error conditions.

 

NOTES

The jBC OSBREAD command reads data from a file starting at a specified byte location (ByteExpr) for a certain length of bytes (LengthExpr), and assigns the data to a variable. OSBREAD performs an operating system block read on a UNIX or Windows NT file.

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. OSBREAD converts CHAR(0) to CHAR(128) when reading a block of characters.  jBC begins reading from the file at the offset specified by ByteExpr.  After successful execution of OSBREAD against a file, the file pointer remains at the next byte after the data read.

Reminder

You must open the file using the OSOPEN command before you use OSBREAD.

 

EXAMPLES

OSBREAD Rec FROM MyFile AT 0 LENGTH 10000

 

RELATED COMMANDS

OSOPEN, OSCLOSE, OSBWRITE, OSREAD, OSWRITE, OSDELETE


jBC