OSREAD

Reads an OS file.

 

COMMAND SYNTAX

OSREAD Variable FROM expression {ON ERROR Statements}  {THEN | ELSE} Statements {END}

 

SYNTAX ELEMENTS

Variable Specifies the variable to contain the data from the read.
expression Specifies the full file path.  If the file resides in the JEDIFILEPATH then just the file name is required.
ON ERROR Statements Conditional jBC statements to execute if the OSREAD 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.
THEN | ELSE

If the OSREAD statement fails it will execute any statements associated with an ELSE clause. If the OSREAD is successful it will execute any statements associated with a THEN clause. Note that the syntax requires either one or both of the THEN and ELSE clauses.

 

NOTES

The jBC OSREAD command reads an entire sequential file and assigns the contents of the file to a variable.  Do not use OSREAD on large files. If the file is too large for the program’s memory, the program aborts and a runtime error message is generated. On large files, use OSBREAD or READSEQ.

jBASE uses the ASCII 0 character (CHAR(0)) as a string-end delimiter. ASCII 0 cannot be used in any string variable within jBC. This command converts CHAR(0) to CHAR(128) when reading a block of data.

 

EXAMPLES

OSREAD MyFile FROM "C:\MyDirectory\MyFile" ELSE PRINT "FILE NOT FOUND"

 

RELATED COMMANDS

OSOPEN, OSCLOSE, OSBREAD, OSBWRITE, OSWRITE, OSDELETE


jBC