Infobasic - 3
Infobasic - 3
Infobasic - 3
Technical Courses
Agenda & Objective
Session-wise plan
Session – I & II
• T24 routines – File Operations
Session – III
• T24 routines – Sequential File Access
OPF
F.READ
F.WRITE
EB.READLIST
READ
WRITE
Programming Flow
<Initialize variables FN.CUSTOMER,F.CUSTOMER,….>
<Open the file using OPF>
i.e. CALL OPF(FN.CUSTOMER,F.CUSTOMER)
Syntax:
CALL F.READ(Filename,record.id,dynamic.array,File.var,Error.var)
Where,
Filename : File Name
Record.id : ID of the record to be read
Dynamic.array : Dynamic array that will hold read record
File.var : File Path
Error.var : Error Variable
Programming Flow
<Initialize variables FN.CUSTOMER,F.CUSTOMER,….>
<Open the file using OPF>
<Read the record using F.READ>
i.e. CALL F.READ
(FN.CUSTOMER,Y.CUSTOMER.ID,R.CUSTOMER,
F.CUSTOMER,Y.CUS.ERR)
Syntax:
CALL F.WRITE(Filename, Record.id, Dynamic array)
Where,
Filename : File Name
Record.id : Record to be written
Dynamic array : Array holding the values to be written on record
Programming Flow
<Initialize variables FN.CUSTOMER,F.CUSTOMER,….>
<Open the file using OPF>
<Read the record using F.READ>
<Assign the value to the dynamic array which we are going to
write>
i.e. CALL F.WRITE
(FN.CUSTOMER,Y.CUSTOMER.ID,R.CUSTOMER)
Insert file
Syntax:
CALL EB.READLIST(1,2,3,4,5 )
Where,
1 : Select Query
2 : List variable that contains only the ID of the selected records
3 : Id of the SAVEDLISTS file (Optional)
4 : No of Records selected (Total Count)
5 : Return code
Example
<Initialize File name FN.CUSTOMER>
SEL.CMD = “SELECT “:FN.CUSTOMER
CALL
EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.RECORDS,RET.
CODE)
SYNTAX:
REMOVE <var> FROM <array> SETTING <set var>
Var : variable which holds the extracted string
Array : Dynamic array from which the string is to be extracted.
Set var : Delimiter by which string is extracted from array.
(2 – FM, 3 – VM, 4 – SM, 0 – End of array)
FREAD READ
Reads the buffer first and executes if the Directly checks for the required data in
required data is in buffer, else checks for the server all the time, without checking
the required data in the server and buffer and executes
executes
FWRITE WRITE
Writes date into the buffer first, that's why Writes data directly into the server
sometimes we have to use
JOURNAL.UPDATE
Write a program
• To check whether field ‘Town Country’ in Customer application
has a value
• If ‘Town Country’ has no value, then update it with ‘INDIA’
Syntax:
OPENSEQ Path{,File} {READONLY} TO FileVar { LOCKED
statements } THEN | ELSE statements
Where,
Path: Specifies relative or absolute path of target file/directory
File: Specifies additional path information of target file
FileVar: Contains file descriptor of the file opened successfully
Statement: Conditional jBC statements
Syntax:
WRITESEQ Expression {APPEND} TO FileVar THEN | ELSE
statements
(Or)
WRITESEQF Expression {APPEND} TO FileVar THEN | ELSE
statements
Where,
Expression: Specifies the variable to contain next record from
sequential file
Syntax:
READSEQ Variable FROM FileVar THEN | ELSE statements
Where,
Variable: Specific variable to contain next record from sequential
file
FileVar: Specific file descriptor of file opened successfully
Statement: Conditional jBC statement
Sequential file is created and data is written into the file and
read from jBase non-hashed file