PRG6.Accessing Sequential Files In jBASE

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Welcome to the learning unit ‘Accessing Sequential Files in jBASE.

In this unit you will


learn how to create and manipulate sequential files in jBASE.

PRG.Accessing Sequential Files In jBASE 1


After completing this learning unit, you will be able to:

Create sequential files in jBASE


Read and Write data into sequential files

PRG.Accessing Sequential Files In jBASE 2


T24 uses j4 files to store data, but there are also some sequential files that are used.
Mostly internal logs likes &HOLD& and &COMO& are sequential files. T24 supports
batch processing using the OFS module, so this too uses sequential files. Type UD
files are sequential files.

PRG.Accessing Sequential Files In jBASE 3


Sequential files and records within them in jBASE can be of two types. Within a type
UD, every record that is created is a file by itself.

The other notion– which is followed by most software – is where records are lines,
delimited by a line feed/carriage return within a single physical file.

Some apps in T24 use a mix of the two modes a classic example of this been
&COMO&

PRG.Accessing Sequential Files In jBASE 4


You will now learn how to create a sequential file in jBASE using a simple program.

PRG.Accessing Sequential Files In jBASE 5


First of all, you must create a type UD (directory) to store the sequential file that you
are about to create.

PRG.Accessing Sequential Files In jBASE 6


To create a sequential file within the UD that you just created, you must use the
OPENSEQ command so that a file pointer variable gets set to the exact location where
the sequential file mist be created. The command above, creates a record with ID 1
within the UD file called TEMENOS.SEQ.

PRG.Accessing Sequential Files In jBASE 7


If the OPENSEQ fails for any reason, one of them being if the UD TEMENOS.SEQ
does not exist, an error message is printed. If the OPENSEQ is successful, another
message is printed out on screen.

PRG.Accessing Sequential Files In jBASE 8


The WRITESEQ command is used to write data into an already opened sequential file.
In this example the record 1 in TEMENOS.SEQ. The APPEND key word can be used
to write multiple records in a loop. In this case, it appends the new string to the
sequential file on a new line.

PRG.Accessing Sequential Files In jBASE 9


Once you are done using a sequential file it must be closed or in other words the
pointer to it cleared. This is done using the CLOSESEQ command.

PRG.Accessing Sequential Files In jBASE 10


This slide sums up all the steps that were just discussed.

PRG.Accessing Sequential Files In jBASE 11


You will now learn how to read data from a sequential file.

PRG.Accessing Sequential Files In jBASE 12


To read information from an existing file, it must first be opened.
Data can then be read as required
Don’t forgot to close the file after use.

PRG.Accessing Sequential Files In jBASE 13


The READSEQ command is used to read data from an opened sequential file.

PRG.Accessing Sequential Files In jBASE 14


You can put the READSEQ command within a looping structure if there are multiple
records to be fetched from the sequential file. It is important to note here that the
variable ENDOFFILE is not a common variable. It is a user defined variable.

PRG.Accessing Sequential Files In jBASE 15


This is a small sample program that reads the data that was written into the sequential
file that was created in the first example.

PRG.Accessing Sequential Files In jBASE 16


This task is a little more difficult than just writing simple strings into a sequential file. In
this task, you must fetch data from the ACCOUNT application and write it into a
sequential file. Commas are being used as delimiters so that this data can be later
opened using Microsoft Excel.

PRG.Accessing Sequential Files In jBASE 17


This is one more option to open an sequential file. The record ID can be specified
along with the sequential file name and then the OPENSEQ can be executed.
Once a sequential file is opened, only one type of operation can be performed on the
file – Either READ or WRITE.
In order to perform another operation (Either READ or WRITE), the file needs to be
closed and opened again.

PRG.Accessing Sequential Files In jBASE 18


•False
•False
•True
•True
•False

PRG.Accessing Sequential Files In jBASE


You will be able to:

Create sequential files in jBASE


Read and Write data into sequential files

PRG.Accessing Sequential Files In jBASE 20


PRG.Accessing Sequential Files In jBASE 21

You might also like