# OSOPEN

Updated: 10/19/2021, 9:29:48 PM
Created: 10/19/2021, 9:29:48 PM
Last Updated By: Kevin Munoz
Read Time: 1 minute(s)

Tags: file handling

# Description

The OSOPEN command opens a sequential file that does not use CHAR(10) as the line delimiter. The command takes the general form:

OSOPEN filename TO file.var [ON ERROR statements] {THEN | ELSE} statements [END]
1

Where:

  • filename specifies the file to open. filename must include the complete path name unless the file resides in the current directory,
  • TO file.var Specifies a variable to contain a pointer to the file,
  • ON ERROR statements specifies statements to execute if the OSOPEN 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 enters the debugger.

THEN statements Execute if the read is successful.

ELSE statements Execute if the read is not successful or the record (or ID) does not exist.

# Note

Read/write access mode is the default. Omitting READONLY and WRITEONLY will by default specify this access mode.

After opening a sequential file with OSOPEN, use OSBREAD to read a block of data from the file, or OSBWRITE to write a block of data to the file. You also can use READSEQ to read a record from the file, or WRITESEQ or WRITESEQF to write a record to the file, if the file is not a named pipe. (READSEQ, WRITESEQ, WRITESEQF are line-oriented commands that use CHAR (10) as the line delimiter.)

An example of use would be a program statement that opens the file ‘MYSLIPPERS’ as SLIPPERS.

OSOPEN 'MYSLIPPERS' TO SLIPPERS ELSE STOP
1

Go back tojBASE BASIC.

Go back to Programmers' Reference Guide