3 InfobasicProgrammingInjBASE PDF
3 InfobasicProgrammingInjBASE PDF
No part of this document may be reproduced or transmitted in any form or by any means,
electronic or mechanical, for any purpose, without the express written permission of TEMENOS Holdings NV.
Infobasic Programming - jBASE
“Warning: This document [Banking Introduction – Courseware] is protected by copyright law and international treaties.
No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any
purpose, without the express written permission of TEMENOS Holdings NV
Unauthorized reproduction or distribution of this presentation or any portion of it, may result in severe civil and criminal penalties,
and will be prosecuted to the maximum extent possible under applicable law.”
Table of Content
Objectives............................................................................................................................................. 6
Introduction........................................................................................................................................... 6
Arrays ................................................................................................................................................... 6
Types Of Arrays ................................................................................................................................ 7
Dynamic Arrays ............................................................................................................................. 7
Dimensioned Arrays ...................................................................................................................... 8
Structure Of An Infobasic Program ....................................................................................................... 8
Compiling And Cataloguing Programs And Subroutines....................................................................... 9
Compiling Subroutines ...................................................................................................................... 9
Compiling Programs........................................................................................................................ 10
Writing Infobasic Programs................................................................................................................. 10
Example 1 ....................................................................................................................................... 10
Solution 1 ........................................................................................................................................ 10
Step 1 .......................................................................................................................................... 10
Consolidated Solution 1............................................................................................................... 10
Step 2 .......................................................................................................................................... 11
Step 3 .......................................................................................................................................... 11
Control Structures In Infobasic............................................................................................................ 11
If Then Else..................................................................................................................................... 12
Begin Case End Case ..................................................................................................................... 12
For Loop.......................................................................................................................................... 13
Open Loop ...................................................................................................................................... 13
Built In Infobasic Functions ................................................................................................................. 13
LEN ................................................................................................................................................. 14
COUNT ........................................................................................................................................... 14
DCOUNT......................................................................................................................................... 14
UPCASE ......................................................................................................................................... 14
DOWNCASE ................................................................................................................................... 14
CHANGE......................................................................................................................................... 15
OCONV........................................................................................................................................... 15
Writing Subroutines In Infobasic ......................................................................................................... 15
Structure Of A Subroutine ............................................................................................................... 16
Example 2 ....................................................................................................................................... 16
Solution 2 ........................................................................................................................................ 16
Algorithm ..................................................................................................................................... 16
TEMENOS Training Publications Page 3 of 47 July 2003
T2BTT – R06 – 1.0
Infobasic Programming - jBASE
Step 1 .......................................................................................................................................... 16
OPF ............................................................................................................................................. 17
Step 2 .......................................................................................................................................... 18
F.READ ....................................................................................................................................... 18
Step 3 .......................................................................................................................................... 19
Step 4 .......................................................................................................................................... 20
Consolidated Solution 2............................................................................................................... 20
How Do We Execute This Subroutine From T24? ........................................................................... 21
Debug Statement......................................................................................................................... 22
Example 3 ....................................................................................................................................... 24
Solution 3 ........................................................................................................................................ 24
Algorithm ..................................................................................................................................... 24
Step 1 .......................................................................................................................................... 24
Step 2 .......................................................................................................................................... 24
EB.READLIST ............................................................................................................................. 25
Insight Into EB.READLIST ........................................................................................................... 25
Step 3 And 4................................................................................................................................ 26
Consolidated Solution 3............................................................................................................... 26
Example 4 ....................................................................................................................................... 27
Solution 4 ........................................................................................................................................ 27
Algorithm ..................................................................................................................................... 27
Step 1, 2 ,3 ,4 And 5 .................................................................................................................... 28
Step 6 .......................................................................................................................................... 28
Consolidated Solution 4............................................................................................................... 28
Example 5 ....................................................................................................................................... 30
Solution 5 ........................................................................................................................................ 30
Algorithm ..................................................................................................................................... 30
Step 1 .......................................................................................................................................... 30
Steps 2 And 3 .............................................................................................................................. 30
Step 4 .......................................................................................................................................... 30
F.READU..................................................................................................................................... 30
Step 5 .......................................................................................................................................... 31
F.WRITE...................................................................................................................................... 31
Step 6 .......................................................................................................................................... 32
Consolidated Solution 5............................................................................................................... 32
An Insight Into Reading And Writing In T24 ........................................................................................ 33
CACHE.READ................................................................................................................................. 36
Objectives
• To understand the concept of arrays
• To understand the steps to write a simple routine in Infobasic
• To understand the need to compile and catalogue subroutines
• To understand the working of the jBASE environmental variables JBCDEV_BIN, JBCDEV_LIB,
JBCOBJECTLIST and PATH.
• To understand the need of the jBASE configuration file jLibDefinition
• To understand and use T24 subroutines like OPF, F.READ etc
• To understand and use Infobasic commands like LOOP, REMOVE etc.
• To understand the command that are used to access sequential files
• To understand the creation of subroutines that take in and return arguments
• To understand the creation of functions.
Introduction
As you would be aware by now, T24 uses jBASE as the back end to store its data. All programs that
make up the T24 core are written in a language called Infobasic. Infobasic is a very simple yet
powerful programming language. With its English like statements, it makes programming very simple.
A salient feature of Infobasic is that it does not support data types. All variables in Infobasic are
treated as Dynamic Arrays (Refer 2.1 Arrays). Since Infobasic does not support data types, the need
to declare variables does not arise.
Arrays
Before we understand the various commands and the way to write programs in Infobasic, it is very
essential to understand the concept of arrays.
Every variable that we use occupies a portion of the memory. Usually character variables occupy 1
byte of memory, which have the capacity to store just one character. In case a series of characters
(string) like ‘T24’ has to be stored, then a character variable would not suffice. There comes the need
for arrays. We now need 6 bytes of continuous memory blocks in order to store the string. Sequential
storage of characters that form a string will make storage and retrieval easier and faster. Moreover all
the 6 bytes should have the same name. This is exactly the functionality of an array.
To sum it up, an array is nothing but continuous memory allocation, where in all the bytes have the
same name as that of the array and can be distinguished with the help of a subscript which always
starts with a ‘0’.
Array 1
G L O B U S
0 1 2 3 4 5
Note : In case you wish to access ‘G’ in ‘GLOBUS’ , then you would usually specify Array1[0]
TEMENOS Training Publications Page 6 of 47 July 2003
T2BTT – R06 – 1.0
Infobasic Programming - jBASE
Types Of Arrays
There are two different types of arrays that are supported by Infobasic. They are
I. Dynamic Arrays
II. Dimensioned Arrays
Dynamic Arrays
Dynamic arrays are, as the name implies, dynamic in the number, dimensions and their extents.
Dynamic arrays are especially useful in providing the ability to manipulate variable length records with
a variable length of fields and/or values within fields etc. A dynamic array is just a string of characters
that contain one or more delimiter characters. The delimiter characters are:
A field marker separates each field and a field may contain more than one value separated by a value
marker. Any value may have more than one sub-value separated by a sub-value marker.
Filed1FMField2FM Value1VMValue2VMValue3VMValue4FMField4FMSubValue1SMSubValue2FMField5
Note
All variables in Infobasic are treated as dynamic arrays. Dynamic arrays do not need any explicit
declaration. Initialisation would suffice.
TemenosTrgFMIndiaVMUKVMGenevaFMTechnicalVMFunctionalFM
jBASESMT24VMLendingSMFinancialsFMFMTrainer.1
Please note that the FM, VM and SMs will be stored as characters but will be stored as special
characters.
Dimensioned Arrays
Dimensioned array provide more efficient means of creating and manipulating tables of data elements
where the number of dimensions and the extent (number of elements) of each dimension is known
and is not likely to change. Dimensioned arrays have to be declared using the DIMENSION statement.
Example
To declare a dimensioned array use
DIM ARRAY2(5,3)
5 - > Refers to the number of rows
3 - > Refers to the number of columns
You can also create single dimensioned arrays. This type of dimensioned arrays will only have a fixed
number of rows. The number of columns will unlimited. In this case, each row in the dimensioned
array will be a dynamic array.
DIM ARRAY3(5)
5 - > Refers to the number of rows
Columns - Unlimited
*Comments *Comments
PROGRAM ProgramName SUBROUTINE SubroutineName
Statement1 Statement1
Statement 2 Statement 2
Statement 3 Statement 3
RETURN
END END
Usually, any program or subroutine developed by the user is stored under a directory named BP and
the core T24 programs or subroutines are stored under GLOBUS.BP. Never store user written
programs/subroutines in the GLOBUS.BP directory.
Compiling Subroutines
When T24 is installed, a directory named “globuslib” and “lib” get installed under the home directory
(run directory) of the user. The directory “globuslib” contains the object code of all core subroutines
and the directory “lib” is supposed to contain the object code of all local subroutines. When a
subroutine is compiled, an object code is produced. For instance when a subroutine TEMENOS
whose source is under the BP directory is compiled an object code $TEMENOS is produced and is
placed under the directory BP (The source directory). A subroutine also needs to be catalogued. The
process of cataloguing refers an environmental variable called JBCDEV_LIB to obtain the path where
it has to place the object file that is to be created. Once the path is obtained, the object code is placed
under one of the library files under that path. Therefore, all object codes of all subroutines get stored
under a library file under the path pointed to by the environmental variable JBCDEV_LIB. The library
files mentioned above are controlled by a configuration file named jLibDefinition, which is present
under the jBASE config directory (Referred by the environmental variable JBCGLOBALDIR). The
jLibDefinition file specifies the naming convention of the library files and the maximum size of them as
well. jBASE decides, under which library file the object code has to reside. If none of the existing
library files under the directory pointed by the JBCDEV_LIB have space to store a new object code
then jBASE will automatically create a new library file by referring the jLibDefinition file. jBASE will also
swap object codes from one library file to another in order to utilize the existing space inside the library
files to the maximum.
JBCDEV_LIB=$HOME/lib
JBCOBJECTLIST=$HOME/lib.$HOME/globuslib
Compiling Programs
When T24 is installed, two directories namely “globusbin” and “bin” get installed under the home
directory (run directory) of the user. The directory “globusbin” contains the core T24 executables and
the directory “bin” is supposed to contain the non-core/local executables. When a program is compiled
an executable is produced. For instance when a program TEMENOS whose source is in the BP
directory is compiled, an executable with the name $TEMENOS gets created under the BP (Source
directory). The process of cataloguing refers an environmental variable JBCDEV_BIN to obtain the
directory into which this executable needs to be placed.
When a program is executed, jBASE refers an environmental variable PATH, which contains the
search path of jBASE executables as well. PATH, as you would be aware of by now, is not a jBASE
variable but a UNIX variable and contains the search path of UNIX executables.
JBCDEV_BIN=$HOME/bin
PATH=$HOME/bin:$HOME/globusbin:$PATH
The values of JBCDEV_BIN, JBCDEV_LIB, JBCOBJECTLIST and PATH can be changed accordingly
depending upon the requirement.
Solution 1
Step 1
Write a program to display the string “HELLO WORLD” and store it under the BP directory.
Consolidated Solution 1
JED BP HELLO
New record.
PROGRAM HELLO
CRT "HELLO WORLD"
END
JED is the jBASE editor. Please refer to ‘Using JED Editor’ notes that have been attached to this
course material.
Step 2
Compile and catalog the program. Since this is a local program, the executable needs to go to “bin”
and not “globusbin”. Therefore check the value of JBCDEV_BIN. If it is pointing to any other directory
other than bin change it to point to bin.
echo $JBCDEV_BIN
Note the output. If it is anything other than the bin directory then change the value of JBCDEV_BIN as
follows
export JBCDEV_BIN=$HOME/bin
Please note that the above statement will only change the value of JBCDEV_BIN for the current
session. If you want this change to be permanent, then make the change in the .profile file, logout and
login for the change the take effect.
Please ensure that PATH first points to $HOME/bin, as, if there is a program with the same name and
its executable resides in “globusbin” or any other directory that is specified first in PATH, then that
program only would get executed.
Step 3
Execute the program by typing the following statement at the database prompt.
Jsh-->HELLO
I. If Then Else
II. Begin Case End Case
III. For Loop
IV. Open Loop
If Then Else
The IF clause is used to determine the flow to be executed depending on either the true or false
(successful or unsuccessful) result of the statement. If the statement evaluates to a ‘true’ then the
statements following the THEN clause will get executed. If the statement evaluates to a ‘false’ then the
set of statements following the ‘ELSE’ clause would get executed. In most cases, either the THEN or
the ELSE must be specified; optionally both may be. In certain specific cases the ELSE clause only is
available.
For each of these statements the format of the THEN and ELSE clauses is the same. If the THEN or
ELSE clause is restricted to one statement, on the same line as the test statement, the THEN or ELSE
can be specified in the simple format.
If the THEN or ELSE clause contains more than one statement, or you wish to place it on a separate
line, you must use the multiline format that encloses the statements and terminates them with an END.
Example
IF AGE <= 17 THEN
PRINT “AGE IS LESSER THAN OR EQUAL TO 17”
PRINT “MINOR”
END
ELSE
PRINT “MAJOR”
END
Use the CASE statement to alter the sequence of instruction execution based on the value of one or
more expressions. If expression in the first CASE statement is true, the following statements up to the
next CASE statement are executed. Execution continues with the statement following the END CASE
statement. If the expression in a CASE statement is false, execution continues by testing the
expression in the next CASE statement. If it is true, the statements following the CASE statement up
to the next CASE or END CASE statement are executed. Execution continues with the statement
following the END CASE statement. If more than one CASE statement contains a true expression,
only the statements following the first such CASE statement are executed. If no CASE statements are
true, none of the statements between the BEGIN CASE and END CASE statements are executed.
Example
USERNAME = @LOGNAME
BEGIN CASE
CASE USERNAME = “TOM”
DEPARTMENT = “HR”
CASE USERNAME = “DICK”
DEPARTMENT = “ADMIN” If none of the Case statements
CASE 1 (or OTHERWISE) match then this statement
“DEPARTMENT NOT FOUND” would get executed
END CASE
For Loop
Use the For Loop to execute a set of statements repeatedly for specific number of times. The counted
loop uses a variable to hold the iteration count. This commences at the start value for the loop is
automatically incremented by a step value for each iteration. Once it has passed the end value, the
loop terminates.
Example
FOR COUNTER = 1 TO 10
The string TEMENOS GLOBUS
CRT “TEMENOS GLOBUS” will get printer 10 times”
NEXT COUNTER
Open Loop
The open loop specifies a more powerful loop construction that will continue to iterate until a condition
is met to terminate this. The condition is held in the WHILE clause. The REPEAT statement takes the
control back to the first line after the LOOP statement.
Example
LOOP
CRT “Input 2 Numbers”
INPUT Y.NUM1 A condition is being checked using the
INPUT Y.NUM2 While clause. ‘:’ is the concatenation
WHILE Y.NUM1:Y.NUM2 operator in Infobasic. The While statement
specified here checks if Y.NUM1 and
CRT “Total “ : Y.NUM1 + Y.NUM2
Y.NUM2 contain values.
REPEAT
LEN
COUNT
DCOUNT
UPCASE
DOWNCASE
CHANGE
OCONV
LEN
Use the LEN function to return the number of characters in a string.
Example
Var1 = LEN(“TEMENOS”)
Var1 = 8
COUNT
Use the COUNT function to return the number of times a substring is repeated in a string value.
Example
DCOUNT
Use the DCOUNT function to return the number of delimited fields in a data string.
Example
UPCASE
Use the UPCASE function to convert the passes string to UPPER CASE.
Example
Var1 = UPCASE(“temenos”) Var1 is now TEMENOS
DOWNCASE
Use the DOWNCASE function to convert the passed string to lower case
Example
Var1 = DOWNCASE(“TEMENOS”) Var1 is now temenos
CHANGE
Use the CHANGE function to replace a substring in expression with another substring. If you do not
specify occurrence, each occurrence of the substring is replaced.
Example
Var1 = CHANGE(“TEMENOOS”,”OO”,”O”) Var1 is now TEMENOS
OCONV
Use the OCONV function to convert string to a specified format for external output. The result is
always a string expression.
Example
SUBROTUINE SubroutineName
$INSERT I_COMMON Insert Files
$INSERT I_EQUATE
Actual Statements
Actual Statements
RETURN
END
Structure Of A Subroutine
All subroutines have to compulsorily begin with the line SUBROUTINE SubroutineName and end with
RETURN and END. The subroutine name and the name of the file where the subroutine is to be
stored must have the same name.
Insert files are similar to ‘Include’ files that you might have used in ‘C’ and ‘C++’ programs. There are
number of insert files available. Each one of them contains some inbuilt functionality that can be used
in our programs/subroutines. This enables re-usability of code.
I_COMMON and I_EQUATE are two main insert files available in T24. I_COMMON defines all
common global variables that can be used across subroutines and the file I_EQUATE initializes those
common variables. It is a good practice to include these files in every subroutine we write irrespective
of whether we are to use common global variables or not. These insert files are available under the
directory GLOBUS.BP.
It has to be noted that common variables get loaded when a user signs on into T24. Many of the
common variables get loaded when a user signs on and many of them get loaded when certain
applications are started.
Example
R.USER – Will contain the currently signed on user’s USER record. If any changes are made to the
user record, these changes will take effect only if he logs off and logs in again.
ID.NEW – Will contain the ID of an application (either when F3 is pressed or when the ID is input
manually).
Example 2
Write a subroutine that will display the details (Id, Mnemonic and Nationality)of a customer whose id is
100069
Solution 2
Algorithm
Step 1. Open the Customer File
Step 2. Read the Customer file and extract the record with id 100069
Step 3. From the extracted record obtain the mnemonic and nationality
Step 4. Display the customer id, mnemonic and nationality.
Step 1
In order to open the Customer file we can use the command OPEN.
OPEN FBNK.CUSTOMER
When we use the OPEN to open a file, we need to supply the exact file name (along with the prefix). If
programs are written using OPEN statements, they do not become portable across branches of a
bank, as each branch will have a different mnemonic to identify itself uniquely.
For Instance
TEMENOS Training Publications Page 16 of 47 July 2003
T2BTT – R06 – 1.0
Infobasic Programming - jBASE
Bank XYX
In Branch1
In a subroutine we open the customer file by using UniVerse OPEN statement
OPEN FBR1.CUSTOMER
In Branch2
If the above subroutine with the OPEN statement were to be executed in this branch,
the subroutine would return a fatal error saying that it cannot open the file. The name
of the customer file in this branch is FBR2.CUSTOMER.
In order to overcome this problem or program portability, we need to use the core T24 subroutine OPF
instead of Open.
OPF
OPF is a core T24 subroutine that is used to open files.
Syntax
CALL OPF(Parameter1,Parameter2)
Example
FN.CUS = ‘F.CUSTOMER’
F.CUS = ‘’
CALL OPF(FN.CUS,F.CUS) Code to open the Customer file
Working Of OPF
Both the parameters are to be stored in variables and then passed to the OPF subroutine.
FN.CUS = ‘F.CUSTOMER’
The name of the variable that is to store the file name has to begin with “FN.” followed by a string that
denotes the file that is to be opened. Just supply the value “F.” followed by the name of the file to open
like above to the variable FN.CUS.
When the OPF subroutine gets executed, the COMPANY file is read in order to obtain the mnemonic
of the bank. Then the FILE.CONTROL record of the file is read to find out the type of file (INT, CUS or
FIN). Once the file type is extracted, the ‘F.’ in the file name gets replaced with
Step 2
In order to read the Customer file use the T24 subroutine F.READ.
F.READ
Syntax
F.READ(<filename>,<id of record>,<dynamic array that contains the record that is read>,<file
path>,<error variable>)
Example
Y.CUSID = “100069”
CALL F.READ(FN.CUS,Y.CUSID,R.CUSTOMER,F.CUS,CUS.ERR)
Note R.CUSTOMER is a dynamic array that will hold the extracted customer record. It does not
require declaration, but initializing it to a ‘’ would be a good programming practice. The error variable
CUS.ERR1 will hold ‘null’ if the read is successful else will hold a numeric value. Note that the id of the
record has been supplied using a variable.
Contents Of R.CUSTOMER
Note that the values of fields have been delimited using a field marker( ) and multi values have been delimited
using the value marker(ÿ). There aren’t any sub values in this customer record.
DAOHENGBK DAO HENG BANK INC DAO HENG BANK INC 119 ASIAN MANSION 209 DELA ROSA S
T LEGASPI VILLAGE MAKATI CITY MAN PH 1111 90 8100 999 PH 4 PH 20000101 2
0000101 1 1 18_RICKBANAT1ÿ28_ANDREABARNES1 0006121042 18_RICKB
ANAT1 US0010001 1
Step 3
In order to obtain the mnemonic and the nationality of the customer, we need to access the dynamic
array R.CUSTOMER. To extract values from a dynamic array, angular brackets “< >” need to be used.
(Use ‘()’ for dimensioned arrays)
We can extract data from the dynamic array by specifying field positions as follows
Y.MNEMONIC = R.CUSTOMER<1>
or by specifying the actual name of the field. It is always advisable to use field names because field
positions could change from one release of T24 to another. Here 1 is the field position of the field
mnemonic in the CUSTOMER file.
How does one know the field numbers and the field names?
Most of the files in T24 have insert files that begin with ‘I_F.’ followed by the name of the file. They will
be available under the GLOBUS.BP directory. These files hold the names and the field positions of the
various fields. These fields could have prefixes/suffixes.
Therefore to extract the mnemonic and nationality of the customer we need to use the following code
Y.MNEMONIC = R.CUSTOMER<EB.CUS.MNEMONIC>
Y.NATIONALITY = R.CUSTOMER<EB.CUS.NATIONALITY>
Step 4
To display the Id, Mnemonic and Nationality values extracted we could use the Infobasic command
CRT.
Syntax
CRT VariableName/”String”
Example
CRT “Customer Id : “:Y.CUSID
CRT “Customer Mnemonic : “:Y.MNEMONIC
CRT “Customer Nationality : “:Y.NATIONALITY
Consolidated Solution 2
RETURN
PROCESS:
CALL F.READ(FN.CUS,Y.CUS.ID,R.CUSTOMER,F.CUS,CUS.ERR1)
Y.MNEMONIC = R.CUSTOMER<EB.CUS.MNEMONIC>
Y.NATIONALITY = R.CUSTOMER<EB.CUS.NATIONALITY>
CRT “Customer Id: “:Y.CUS.ID
CRT “Customer Mnemonic: “:Y.MNEMONIC
CRT “Customer Nationality: “:Y.NATIONALITY
RETURN
END
Note
In the above subroutine, the code has been split and made part of 3 different paragraphs. In order to
achieve modularity and to make maintenance of code easier, it is advisable to make use of
paragraphs. Every paragraph has to have a name and has to end with a RETURN statement. A
GOSUB ParagraphName statement takes the control to that specific paragraph. Once the statements
inside the paragraph get executed, the RETURN statement takes the control back to the line after the
GOSUB statement that actually invoked this paragraph. This type of modular programming needs to
be used for a lengthy subroutine. In case the number of lines that constitute the subroutine is very less,
the programmer could choose to write code using the Top Down approach of programming where
there will be no paragraphs at all.
Note
If we type CUS.DISPLAY.DETAILS in the Awaiting Application prompt we would see the output.
Debug Statement
The DEBUG statement shows the execution of a subroutine line by line.
Let us add the DEBUG statement to the subroutine and see the display (Add it at the point from where
you wish to see the execution of the subroutine line by line)
SUBROUTINE CUST.DISPLAY.DETAILS
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.CUSTOMER
GOSUB INIT
GOSUB OPENFILES
GOSUB PROCESS
RETURN
INIT:
DEBUG
Ensure that you compile and catalogue after making any changes to the subroutine.
Execute The Subroutine
Type the name of the subroutine in the ‘Awaiting Application’ prompt and see the execution of the
subroutine line by line.
0020 OPENFILES:
jBASE debugger->S
0021 CALL OPF(FN.CUS,F.CUS)
jBASE debugger->S
0022 RETURN
jBASE debugger->S
0023 PROCESS:
jBASE debugger->V FN.CUS
FN.CUS : FBNK.CUSTOMER
jBASE debugger->V F.CUS
F.CUS : File '../mbdemo.data/st/FBNK.CUST000'
jBASE debugger->S
0024 CALL F.READ(FN.CUS,Y.CUS.ID,R.CUSTOMER,F.CUS,CUS.ERR1)
jBASE debugger->S
0025 Y.MNEMONIC = R.CUSTOMER<EB.CUS.MNEMONIC>
jBASE debugger->S
0026 Y.NATIONALITY = R.CUSTOMER<EB.CUS.NATIONALITY>
jBASE debugger->S
0027 CRT "Customer Id: ":Y.CUS.ID
jBASE debugger->V Y.MNEMONIC
Y.MNEMONIC : TAKIZAKIT
jBASE debugger->V Y.NATIONALITY
Y.NATIONALITY : JP
jBASE debugger->S
Customer Id: 1038
0028 CRT "Customer Mnemonic: ":Y.MNEMONIC
jBASE debugger->S
Customer Mnemonic: TAKIZAKIT
0029 CRT "Customer Nationality: ":Y.NATIONALITY
jBASE debugger->S
Customer Nationality: JP
0030 RETURN
jBASE debugger->Q
Are you sure ?Y
jBASE debugger , QUIT from program 'EX'
jsh geneva ~ -->
Note
Some DEBUGger commands
Example 3
Modify example 1 to display the id, mnemonic and nationality of all customers.
Solution 3
Algorithm
Step 1. Open the Customer File
Step 2. Select all the customer ids
Step 3. Remove one customer id from the selected list
Step 4. For the extracted customer id extract the corresponding record from the customer file
Step 5. From the extracted record extract the mnemonic and nationality
Step 6. Display the customer id, mnemonic and the nationality
Repeat Steps 3 to 6 for all customers
Step 1
As you would be aware by now that we need to use OPF to open any file in T24
FN.CUS = ‘F.CUSTOMER’
F.CUS = ‘’
CALL OPF(FN.CUS,F.CUS)
Step 2
We need to select all the customer ids from the Customer file. In order to achieve this we need to
execute a Select statement that will pick up all the Customer ids. Select statements can be executed
within subroutines. In order to execute select statements within a subroutine, we need to first assign
the select statement to a variable and then execute the contents of the variable using the core T24
subroutine EB.READLIST. Please note that a Select statement can only return the ids from the file on
which the Select statement is based.
EB.READLIST
EB.READLIST is a core T24 subroutine that is used to execute a Select statement within a subroutine
Syntax
EB.READLIST takes in 5 parameters.
1 - The select statement to be executed. Give the name of the variable that holds the select statement
here.
2 - The name of a dynamic array that will hold the result of the select statement. Please note that a
select statement here can only select ids from the respective file. Therefore this dynamic array will
only hold the ids of the records that have been selected. All the ids are delimited by a field marker
(FM).
3 - This is an optional parameter. This is the name of a file in the hard disk that can hold the result of
the select statement. Usually this is set to NULL (‘’)
4 - A variable that will hold the number of records selected.
5 - A variable to hold the return code. Will contain null if the select statement was successful else will
contain 1 or 2.
Note the space. If this space is not
given then SEL.CMD will contain
“SELECTFBNK.CUSTOMER” thus
resulting in an error in EB.READLIST
SEL.CMD = “SELECT “:FN.CUS
CALL EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.REC,CUS.ERR)
2. If a plain SELECT (with no conditions and not a sorted select) is passed, then EB.READLIST
a. Does an OPF of the file whose records you require
b. Makes the file pointer (F. ) point to the beginning of the file
c. Extracts the IDs one after the other returns the list of IDs to the user.
This method is called ‘Executing An Internal Select’
The second method is faster when compared to the first one, as there is no select that is actually
executed on the file.
Use the second method when you wish to process all or most of the records in a file. If you wish to
process only a few records in a file, then the first method is ideal.
Step 3 And 4
Use LOOP and REMOVE (Discussed Earlier) to repeat Steps 3 to 6
Consolidated Solution 3
*Subroutine to display the mnemonic and nationality of all customers
SUBROUTINE CUS.DISPLAY.DETAILS
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.CUSTOMER
DEBUG
GOSUB INIT
GOSUB OPENFILES
GOSUB PROCESS
RETURN
INIT:
FN.CUS = 'F.CUSTOMER'
F.CUS = ''
Y.CUS.ID = ''
R.CUSTOMER = ''
CUS.ERR1 = ''
Y.MNEMONIC = ''
Y.NATIONALITY = ''
SEL.CMD = ''
SEL.LIST = ''
NO.OF.REC = 0
RET.CODE = ''
RETURN
OPENFILES:
CALL OPF(FN.CUS,F.US)
RETURN
PROCESS:
SEL.CMD = "SELECT ":FN.CUS
CALL EB.READLIST(SEL.CMD,SEL.LIST,'',NO.OF.REC,RET.CODE)
LOOP
REMOVE Y.CUS.ID FROM SEL.LIST SETTING POS
WHILE Y.CUS.ID:POS
TEMENOS Training Publications Page 26 of 47 July 2003
T2BTT – R06 – 1.0
Infobasic Programming - jBASE
CALL
F.READ(FN.CUS,Y.CUS.ID,R.CUSTOMER,F.CUS,CUS.ERR1)
Y.MNEMONIC = R.CUSTOMER<EB.CUS.MNEMONIC>
Y.NATIONALITY = R.CUSTOMER<EB.CUS.NATIONALITY>
CRT "Customer Id: ":Y.CUS.ID
CRT "Customer Mnemonic: ":Y.MNEMONIC
CRT "Customer Nationality: ":Y.NATIONALITY
REPEAT
RETURN
END
Note
Use the REMOVE statement to successively extract dynamic array elements that are separated by
system delimiters. When a system delimiter is encountered, the extracted element is assigned to
variable.
In order to execute the above subroutine, we need to compile and catalogue it. An entry in the
PGM.FILE has to be made to execute it from within T24. In order to see the execution of the
subroutine line by line, we need to add the DEBUG statement.
Example 4
Modify Example 3 to store the extracted mnemonic and nationality of all customers in an
array(do not display them) delimited by a ‘*’. The array should contain data as follows
CusId*Mnemonic*NationalityFMCusId*Mnemoic*Nationality
Solution 4
Algorithm
Step 1. Open the Customer File
Step 2. Select all the customer ids
Step 3. Remove one customer id from the selected list
Step 4. For the extracted customer id extract the corresponding record from the customer file
Step 5. From the extracted record extract the mnemonic and nationality
Step 6. Store the customer id, mnemonic and the nationality in a dynamic array
Repeat Steps 3 to 6 for all customers
Step 1, 2 ,3 ,4 And 5
As discussed earlier we could go ahead and use OPF, F.READ, LOOP, REMOVE and REPEAT to
accomplish the above-mentioned steps.
Step 6
In order to append the extracted values into an array we could use the following method.
ArrayName<-1> = Value
In our case, once we extract the mnemonic and the nationality of the customer we could concatenate
the id, mnemonic and the nationality of the customer delimited with a ‘*’ and then store it in a dynamic
array.
Every time a new value comes in, the existing values get pushed down by one position. This is
achieved by the ‘-1’ that we specify along with the array name. All values get appended, delimited by a
field marker ‘FM’.
MAINARRAY<-1> = Y.CUSID:’*’:Y.MENMONIC:’*’:Y.NATIONALITY
The array will look like this after all values have been concatenated
Consolidated Solution 4
*Subroutine to store the id, mnemonic and nationality of all
*customers in an array
SUBROUTINE CUS.DISPLAY.DETAILS
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.CUSTOMER
GOSUB INIT
GOSUB OPENFILES
GOSUB PROCESS
RETURN
TEMENOS Training Publications Page 28 of 47 July 2003
T2BTT – R06 – 1.0
Infobasic Programming - jBASE
INIT:
FN.CUS = 'F.CUSTOMER'
F.CUS = ''
Y.CUS.ID = ''
R.CUSTOMER = ''
CUS.ERR1 = ''
Y.MNEMONIC = ''
Y.NATIONALITY = ''
SEL.CMD = ''
SEL.LIST = ''
NO.OF.REC = 0
RET.CODE = ''
CUS.DETAILS.ARRAY = ''
RETURN
OPENFILES:
CALL OPF(FN.CUS,F.CUS)
RETURN
PROCESS:
SEL.CMD = "SELECT ":FN.CUS
CALL EB.READLIST(SEL.CMD,SEL.LIST,'',NO.OF.REC,RET.CODE)
LOOP
REMOVE Y.CUS.ID FROM SEL.LIST SETTING POS
WHILE Y.CUS.ID:POS
CALL F.READ(FN.CUS,Y.CUS.ID,R.CUSTOMER,F.CUS,CUS.ERR1)
Y.MNEMONIC = R.CUSTOMER<EB.CUS.MNEMONIC>
Y.NATIONALITY = R.CUSTOMER<EB.CUS.NATIONALITY>
CUS.DETAILS.ARRAY<-1>=
Y.CUS.ID:'*':Y.MNEMONIC:'*':Y.NATIONALITY
REPEAT
RETURN
END
Note :
In order to execute the above subroutine, we need to compile and catalogue it. An entry
in the PGM.FILE has to be made to execute it from within T24. In order to see the execution of
the subroutine line by line, we need to add the DEBUG statement.
Example 5
As a part of the COB process in T24, all savings accounts that have balance less than 5000 need to
be charged a fee. For this purpose you are expected to create a local reference field by name
CHARGE in the Account application and write a subroutine that will check the working balance of all
savings accounts, and if the working balance is lesser than 5000 then set the value in the local
reference field CHARGE to ‘Y’. As a part of the COB process in T24, one of the COB routines will
deduct a charge from all accounts which have this field set to ‘Y’.
Solution 5
Algorithm
Step 1 . Create the local reference field CHARGE using the LOCAL.TABLE application and attach it to
the ACCOUNT application using the LOCAL.REF.TABLE application.
Step 2. Open the ACCOUNT file
Step 3.Select all accounts with category = 6001(this category might differ from one T24 installation to
another).
Step 4.For each of the accounts selected, read the corresponding record from the ACCOUNT file
Step 5.Check the working balance of the account and if the balance is less than 5000 then write the
entire ACCOUNT record into the ACCOUNT file with the local reference field CHARGE set to ‘Y’
Step 6.Update the F.JOURNAL file.
Repeat steps 3 to 5 for all accounts using the LOOP and REPEAT statements.
Step 1
Create the local reference filed CHARGE in the ACCOUNT application using the LOCAL.TABLE and
the LOCAL.REF.TABLE applications.
Steps 2 And 3
As discussed earlier use OPF and EB.READLIST.
Step 4
Now we need to read the record from the ACCOUNT file. Normally we would use the F.READ
statement to read a record from a file. But we need to understand that , when we read a record, we
only obtain a shared lock on the record and hence multiple people can read the record simultaneously.
Since the record that we are to read by might updated by us, we need to ensure that we have
exclusive control over the record. Hence we need to use F.READU instead of F.READ.
F.READU
Parameters
FILEID file name
KEY record-id
REC record returned
F.FILEID file variable
ER returning error message
Step 5
Once the working balance has been extracted and is found to be lesser then 5000, now the local
reference field CHARGE needs to be set to ‘Y’ and the entire account record needs to be written on to
the ACCOUNT file.
R.ACCOUNT<AC.LOCAL.REF,1> = ‘Y’.
Note that there is just one physical field called LOCAL.REF in most of the applications in T24. By
using LOCAL.TABLE and the LOCAL.REF.TABLE applications, we are just multi-valuing the field
LOCAL.REF and giving the new multi value field a new name. Therefore, once a local reference field
is created, it would not affect the physical layout of the file(would not affect the dict) but will only affect
the STANDARD.SELECTION. All local reference fields will have an entry in the SS application with
the Usr Type set to ‘I’ – I descriptor.
F.WRITE
F.WRITE is a core T24 subroutine that is used to write a record on to a file.
When the system is in the Online mode, as mentioned earlier, the write will only happen to the cache.
It is only when a subsequent call to JOURNAL.UPDATE is encountered, the data will be flushed to the
disk.
JOURNAL.UPDATE is a core T24 routine that takes care of updating the F.JOURNAL file and also
ensures transaction management. Please note that JOURNA.UPADTE, if called when the system is in
Batch mode, will not update the JOURNAL fie.
Transaction management can be explicitly triggered in T24 using the EB.TRANS routine.
Statement 1
Statement 2
Statement 3
CALL EB.TRANS(“END”, ‘End of transaction block”)
If it any point within a transaction block the transaction needs to aborted, the T24 subroutine
TRANSACTION.ABORT can be called.
CALL TRANSACTION.ABORT
Syntax
F.WRITE(<filename>,<id of record>,<dynamic record variable>)
Example
CALL F.WRITE(FN.ACC,Y.AC.ID,R.ACCOUNT)
Step 6
Use the T24 subroutine JOURNAL.UPDATE to update the F.JOURNAL file.
CALL JOURNAL.UPDATE(Y.AC.ID)
Note
While writing subroutines that would get executed during the Online stage of T24, a call to F.WRITE
will fail if it does not find a subsequent call to JOURNAL.UPDATE. During the batch stage, since the
F.JOURNAL file is not maintained, a call to F.WRITE does not require a subsequent call to
JOURNAL.UPDATE.
Consolidated Solution 5
*Subroutine to check if the balance in all savings accounts are less than
*5000 and if so, update a local reference field in the ACCOUNT file called
*CHARGE to ‘Y’.
SUBROUTINE ACC.BAL.CHECK
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.ACCOUNT
GOSUB INIT
GOSUB OPENFILES
GOSUB PROCESS
INIT:
FN.ACC = ‘F.ACCOUNT’
F.ACC = ‘’
Y.AC.ID = ‘’
R.ACCOUNT = ‘’
Y.ACC.ERR = ‘’
RETRY = ‘’
RETURN
OPENFILES:
CALL OPF(FN.ACC,F.ACC)
RETURN
PROCESS:
SEL.CMD = “SELECT “:FN.ACC:” WITH CATEGORY = 6001”
CALL EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.REC,RET,CODE)
LOOP
REMOVE Y.ACC.ID FROM SEL.LIST SETTING POS
WHILE Y.ACC.ID:POS
CALL
F.READU(FN.ACC,Y.AC.ID,R.ACCOUNT,F.ACC,Y.ACC.ERR,RETRY)
IF R.ACCOUNT<AC.WORKING.BALANCE> < 5000 THEN
R.ACCOUNT<AC.LOCAL.REF,1> = ‘Y’
CALL F.WRITE(FN.ACC,Y.ACC.ID,R.ACCOUNT)
END
Y.AC.ID = ‘’
R.ACCOUNT = ‘’
REPEAT
CALL JOURNAL.UPDATE(Y.ACC.ID)
RETURN
END
In the above example, F.WRITE is called within a loop and JOURNAL.UPDATE is called outside the
loop. In this case the system is in Online mode and hence all the writes triggered by F.WRITE would
happen only to the cache. It is only when the control comes out of the loop the data from the cache will
actually get flushed to the disk. Care should be taken when calling F.WRITE within a loop – it might
lead to using up all the cache.
Working of F.READ
1. Obtain the file name and the record id
2. Perform SMS validations
3. Check if the record is in cache. If it is in cache, will fetch it
4. If it is not in cache, read from the file in the disk and load the record into cache
Working of F.READU
1. Obtain the file name and record id
2. Perform SMS validations
3. Check if the record is in cache and if so, check if it is locked. If not locked, go to the disk and
lock it
4. If the record is not in cache, read and lock the record from the disk
F.READU holds info of all record locks so that they can be released during a transaction abort.
Whenever we lock a record using F.READU, the lock gets released when
a. That record is written back to the file
b. When the program terminates
c. When an explicit RELEASE statement is encountered
In T24, in many routines, even if there is no explicit RELEASE statement, the locks get releases. This
is because of the RELEASE statement in JOURNAL.UPDATE.
Working of F.READV
Similar to F.READU, but fetches only one field of the record unlike F.READ that fetches the whole
record.
READ: Extract data from a file. F.READ and F.READV call READ internally to extract data.
READU: Extract data from a file and lock it. F.READU internally calls this to extract data.
Outgoing Parameters:
Value of the field that has been fetched
CALL DBR(<FileName:FM:FldToBeFetched:FM:”LangSpecFld”>,<ID>,<RetVar>)
CALL DBR(“CUSTOMER”:FM:EB.CUS.SHORT.NAME:FM:”L”:,100069,Y.RET.VAL)
All the above routines are core T24 routines that can be used to extract data from T24. All these
routines in-turn have to call Infobasic commands to actually obtain data. Following are the various
Infobasic commands that can be used to extract data.
TRANS
This is a jBASE command that is used to fetch the value of a particular field from a file. This is similar
to DBR, just that this is a jBASE function and hence is faster than DBR. The file t be accessed using
TRANS need not be explicitly opened as TRANS would do it internally.
<ExtractedValue> = TRANS(<FileName>,<ID>,<FieldName>,”X”)
FileName : Actual name of the file to be opened
X: Default action code to return the value of the field specified.
Y.SHORT.NAME = TRANS(“FBNK.CUSTOMER”,100069,EB.CUS.SHORT.NAME,”X”)
CACHE.READ
CACHE.READ is a routine that is used to read a record from a file in T24. CACHE.READ will
• Check if the record required is in cache
• Is yes, check if it is not older than the number of seconds specified in the field
CACHE.EXPIRY in SPF. If not older, extract the record and give it to the user
• Else will perform an OPF and F.READ to extract the record
• Load the extracted record on to cache
• Return the record to the user.
CACHE.READ
• Is faster than F.READ, we do not have to explicitly open the file using OPF. CACHE.READ, if
not in cache, will perform OPF and extract the record for us.
• Should be used for extracting records that are not frequently updated
• Best used for extracting parameter records
CACHE.READ(FileName,ID,Record,Error)
CACHE.READ is not used to extract a record from a file, but also for executing SELECT statements.
If the string ‘SelectIDs’ is passed to CACHE.READ, it will in turn call EB.READLIST which will execute
an ‘Internal’ select.
If ‘SSelectIDs’ or ‘SselectARs’ is passed to CACHE.READ, it will in turn call EB.READLIST that will
execute the select statement supplied to it.
FATAL.ERROR
Routine to display system errors, log them to the protocol file and exit. The text that needs to be
displayed as a fatal error needs to be set in the common variable TEXT. The FATAL.ERROR routine
takes in one parameter. This parameter can hold any value, but is usually set to the name of the file
on which the fatal error occurred.
TEXT = “Customer File Not Accessible”
CALL FATAL.ERROR(“CUSTOMER”)
The above command will result in updating a record in the PROTOCOL file with the ID : <UserName> .
This user name is the name of the user for whom the fatal error was generated.
Writing Data
We have already learnt that F.WRITE is used to write data on to T24. F.WRITE internally calls WRITE
to actually write.
WRITE
WRITE <Record> ON <Filename>,<ID> ON ERROR <Message>
Please note that when a WRITE is executed on a record that has been locked, the WRITE statement
will release the lock.
Example 6
Write a program that will write a string “Infobasic programming” onto a sequential file.
Algorithm
Step1 . Create a non-hashed file with the name “TEMENOS.SEQ”
SEQ.FILE.NAME = ‘TEMENOS.SEQ’
RECORD.NAME = ‘1’
Use the command OPENSEQ to open a sequential file.
OPENSEQ
OPENSEQ is used to open a non-hashed file. While using OPENSEQ to open non-hashed file, the
record id needs to be supplied as one of the parameters. OPENSEQ will open that record to a pointer.
Syntax
OPENSEQ filename,recordid to pointer
Example
*The else condition in the OPENSEQ statement will be met when there is no record with the *id
mentioned in the variable RECIORD.NAME and the following CREATE statement *would create the
pointer in order for us to create a new record.
The else clause in the CREATE statement would be met when the file name specified in the variable
SEQ.FILE.NAME is an invalid file name. When the file is invalid, there no other option other than to
display an error message and abort.
Step 3
Write the message “Infobasic Programming” on to the file.
Use the command WRITESEQ to write the message on to the file.
WRITESEQ
WRITESEQ is the command that is used to write the data on to a non hashed(sequential file)
Syntax
WRITESEQ Message TO FilePointer ELSE ErrorMessage
The else clause in the WRITESEQ would be met when the file pointer has not been initialized properly
(does not point to a record in a file)
Example
Step 4
Close the file once the operations are complete .Use the CLOSESEQ command to close a sequential
file.
CLOSESEQ
The CLOSESEQ command is used to close a sequential file after all read write operations for that file
are complete.
Syntax
CLOSESEQ FilePointer
Example
CLOSESEQ SEQ.FILE.POINTER
Consolidated Solution 6
PROGRAM SEQFILE.ACCESS.WRITE
SEQ.FILE.NAME = ‘TEMENOS.SEQ’
RECORD.NAME = ‘1’
OPENSEQ SEQ.FILE.NAME,RECORD.NAME TO SEQ.FILE.POINTER ELSE
CREATE SEQ.FILE.POINTER ELSE
CRT “Unable to create file pointer to file
“:SEQ.FILE.NAME
STOP
END
END
CRT “Openseq was successful on file “:SEQ.FILE.NAME
WRITESEQ “Infobasic programming” TO SEQ.FILE.POINTER ELSE
CRT “Unable to perform WRITESEQ”
CLOSESEQ SEQ.FILE.POINTER
END
Example 7
Write a program that will read the data that has been written on to the sequential file TEMENOS.SEQ .
Algorithm
Step 1 : Open the sequential file
Step 2 : Read the data from the sequential file and display it
Step 3 : Close the sequential file
Step 1 and 3
As discussed earlier, use the OPENSEQ command to open the sequential file and the command
CLOSESEQ to close a sequential file.
Step 2
To read the data from the Sequential file, use the command READSEQ
READSEQ
READSEQ is the command that is used to read the data from a sequential file.
Syntax
Variablename : Name of the variable that will hold the data that has been retrieved from the file.
THEN : The THEN clause will be met when the read is successful.
ELSE : The ELSE clause would be met when the read is unsuccessful. The read would fail if the file
pointer is not initialized properly.
Example
Consolidated Solution 7
PROGRAM SEQFILE.ACCESS.READ
SEQ.FILE.NAME = ‘TEMENOS.SEQ’
RECORD.NAME = ‘1’
OPENSEQ SEQ.FILE.NAME,RECORD.NAME TO SEQ.FILE.POINTER ELSE
CREATE SEQ.FILE.POINTER ELSE
CRT “Unable to create file pointer to file “:SEQ.FILE.NAME
STOP
END
END
CRT “Openseq was successful on file “:SEQ.FILE.NAME
READSEQ Y.MSG FROM SEQ.FILE.POINTER THEN
CRT “Message Extracted :”:Y.MSG
END
ELSE
CRT “Unable to read from file “
END
CLOSESEQ SEQ.FILE.POINTER
END
Note
1. When a read and write operations are performed on a sequential file in the same program,
after WRITESEQ is performed, to use the same file pointer again for a subsequent READSEQ,
the file pointer must be initialized, meaning, do a CLOSESEQ and an OPENSEQ. The same
rule applies when a WRITESEQ is to follow READSEQ in the same program.
2. An OPENSEQ command can also be used to open a file provided along with the path of the
file and the id.
SEQ.FILE.NAME = ‘./TEMENOS.SEQ/1’
OPENSEQ SEQ.FILE.NAME TO SEQ.FILE.POINTER
All the other WRITESEQ, READSEQ, CLOSESEQ statements will remain the same.
Example 8
Step 1
Create a subroutine that will accept 2 integer values, multiply them and return the result in a variable.
SUBROUTINE DEMO.CALLED.RTN(ARG.1,ARG.2,ARG,3)
ARG.3 = ARG.1 * ARG.2
RETURN
END
While defining subroutines in Infobasic, we cannot specify which are the incoming and which are the
return parameters. Therefore just specify the arguments one after the other along with the subroutine
definition as done above. Since the subroutine is storing the result in the variable ARG.3, the system
would understand that ARG.3 is the return parameter.
Step 2
Create another subroutine that would supply the values and call the DEMO.CALLELD.RTN.
SUBROUTINE DEMO.CALLING.RTN
VAR.1 = 10
VAR.2 = 20
VAR.3 = ‘’
CALL DEMO.CALLED.RTN(VAR.1,VAR.2,VAR.3)
PRINT ‘Result “:VAR.3
RETURN
END
Example 9
Step 1
Create a function that will accept 2 integer values, multiply them and return the result in a variable.
FUNCTION DEMO.FUNCTION(ARG.1,ARG.2)
Step 2
Now the function defined above can be called from any program/subroutine. Now create a subroutine
that would supply values and call the above-defined function. When calling a function, the function
needs to be defined first using the DEFFUN command and only then the function should be called.
SUBROUTINE DEMO.SUB.CALLING.RTN
VAR.1 = 10
VAR.2 = 20
DEFFUN DEMO.FUNCTION(VAL.1,VAL.2)
VAR.3 = DEMO.FUNCTION(VAR.1,VAR.2)
CRT “Result :”:VAR.3
RETURN
END
Incase of a function, only the incoming parameters need to be defined. There can and will be only one
return value and that will directly get assigned to the variable on the right side of the equation as
defined above.
Un-initialized variables VAL.1 and VAL.2 have been given to demonstrate that any variable can be
given at the time of defining a function.
Summary
• Infobasic does not support data types. Variables need not be declared in Infobasic.
• All variables in Infobasic are treated as dynamic arrays
• Dynamic arrays expand or reduce in size depending on the amount of data
• Dimensioned arrays need to be declared using the DIM statement
• FM, VM and SM are delimiters to separate fields, multi values in a field and sub values in a
field respectively
• JBCDEV_LIB is the variable that holds the path where the object code of subroutines need to
be stored
• JBCOBJECTLIST contains the search path of subroutines
• JBCDEV_BIN contains the path where the executables of programs need to be stored
TEMENOS Training Publications Page 43 of 47 July 2003
T2BTT – R06 – 1.0
Infobasic Programming - jBASE
• PATH contains the search path of jBASE executables in addition to the search path of Unix
executables.
• globusbin contains all the core T24 executables
• globuslib contains the object code of all core T24 subroutines
• lib and bin are used to store object codes and executables of local subroutines and programs
respectively.
• jLibDefinition is the jBASE configuration file that controls the creation of library files in jBASE.
• OPF is a T24 routine that is used to open files
• F.READ is a T24 routine that is used to read a record from a file
• EB.READLIST is a T24 routine that is used to execute a select statement
• EB.COMPILE is used to compile and catalog subroutines
• To append data into an array with FM as delimiter use Arrayname<-1>
• OPENSEQ is the command that is used to open a sequential file
• READSEQ is the command that is used to read a sequential file
• WRITESEQ is the command that is used to write data into a sequential file
• CLOSESEQ is the command that is used to close a sequential file
• When and read and a write operation on a sequential file are performed in the same program,
then the file needs to be closed and opened again before it can be read from or written into.
• Functions can take in any number of arguments but can return only 1 value.
Additional Information
LOCATE
LOCATE statement is used to locate the position of a string or determine the position to insert in to
maintain a specific sequence.
Syntax
Additional Information
Sort.Expr :
Example
DAYS = “MON:”FM:”TUE”:FM:”WED”:FM:”THU”:FM:”FRI”
LOCATE “WED” IN DAYS SETTING FOUND ELSE FOUND = 0
CRT “Position of WED in DAYS dynamic array :”:FOUND
LOCATE “SAT” IN DAYS BY “AL” SETTING POS ELSE
INS “SAT” BEFORE DAYS<POS>
END
CRT “Position where SAT has been inserted :”:POS
CRT “Days dynamic array after inserting SAT :”:DAYS
Output
F.DELETE
F.DELETE is also a core T24 subroutine that is used to delete a record from a file.
Syntax
CALL F.DELETE(FN.CUS,Y.CUSID)
Infobasic Commands
MATREAD
MATREAD is a command that is used to read the contents of a dimensioned/dynamic array. You can
specify the id of the record to be picked up from the array. Incase the read is successful, then the
statements following the ‘THEN’ statements are executed else the statements following the ‘ELSE’
statement are executed.
Syntax
Example
The above statement will search for a record with id specified in the variable ID1, if found, it will
transfer the record to the array Array1.
MATWRITE
MATWRITE is used to build a dynamic array from a specified dimensioned array and write it to the file
opened to file.variable using a key of record.id.
Syntax
Example
DIM ARRAY1(5)
MATREAD ARRAY1 FROM TEM1,101 ELSE
MAT ARRAY1 = ‘’
END
MATWRITE ARRAY1 ON TEM1,100
CONVERT
Use the CONVERT command to convert characters to other characters.
Y.STRING = “TEMENOSFMT24”
CONVERT FM TO VM IN Y.STRING
CRT Y.STRING
TEMENOSVMT24
DELETE
Use the DELETE command to delete a record. The F.DELETE T24 routine uses this statement to
delete a record.
DELETE <FileName>,<ID>