Programming Using jBASE Commands PDF
Programming Using jBASE Commands PDF
Slide 3
Understanding Variable Declaration
Slide 4
Understanding Arrays
0 1 2 3 4 5 6
Name[0] = T
Name[1] = E
Name[2] = M
Name[3] = E
Name[4] = N
Name[5] = O
Name[6] = S
Slide 5
Points To Remember
Slide 6
Break The Rules
Slide 7
Break The Rules
Can the variable ARR1 store all types of data and data of any length?
Slide 8
Dynamic Arrays
char [10]
char ARR1[10]
Slide 9
Dynamic Arrays And T24
Filed1FMField2FM Value1VMValue2VMValue3VMValue4FMField4FMSubValue1SMSubValue2FMField5
Slide 10
Understanding FM, VM And SM
5 Free Text
6 Inputter TRAINER.1
Slide 11
Dynamic Array – Data Storage
TemenosTrgFMIndiaVMUKVMGenevaFMTechnicalVMFunctionalFM
jBASESMT24VMLendingSMFinancialsFMFMTrainer.1
Slide 12
Dimensioned Arrays
Dynamic Array 1
Dynamic Array 2
Dynamic Array 3
Dynamic Array 4
Dynamic Array 5
Slide 13
Initialing And Declaring – Is There A Difference
▪ In jBASE
▪ Variables don’t have to be declared
▪ It is a good practice to initialize the variable before using it
score = 0 →Initialization
If score > 100 then ……. → Usage of the variable
Slide 14
Question That You Might Have In Your Mind
Dynamic arrays do not have a data type. That being the case, how do you
decide what to initialize the variable to?
Slide 15
Where Do We Store The Program
Slide 16
Write Your First jBASE Basic Program
▪ Program skeleton
*Comments
*Author
*Date of creation
-----------
----------
END
Slide 17
Write Your First jBASE Basic Program
*Temenos Training
*Jan 2008
PROGRAM MY.FIRST.PROGRAM
END
Slide 18
Compile The Program
Slide 19
Catalog The Program
JBCDEV_BIN=$HOME/bin
PATH=$HOME/bin:$HOME/globusbin:$PATH
Slide 20
Execute The Program
▪ Type the program name at the jsh prompt to execute the program
Slide 21
Task
▪ Create a hashed file with the below mentioned structure to store details of
trainers
Slide 22
Solution – Create The File
Slide 23
Solution – Add The Dictionary Items
Slide 24
Solution – Add The Dictionary Items
Slide 25
Workshop
▪ Create a hashed file with the below mentioned structure to store details of
trainees
Slide 26
Control Structures Before You Proceed Further
END <statements>
END CASE
Slide 27
Control Structures
<statements>
REPEAT
Slide 28
Task
Create a program that will display the following menu and perform the
appropriate operations on the TRAINER file
Slide 29
Algorithm
Slide 30
Algorithm
▪ If choice is 3 (Update)
▪ Accept the @ID
▪ Check if the record exists. If it does
Read and Lock the record from the file
Accept the changes for the various fields
Write the data on to the TRAINER file
▪ If choice is 4 (Delete)
▪ Accept the @ID
▪ Check if the record exists. If it does
Delete the record from the file
▪ If choice is 5 (Exit)
▪ Exit from the menu
Slide 31
Solution
▪ Example
OPEN TRAINER TO F.TRAINER THEN CRT “Open Successful” ELSE CRT “Unable to open
file”
Slide 32
Solution
▪ Create the menu and accept the choice from the user
▪ Example
CRT "Trainer File – Data Manipulation Menu "
CRT " *************************************"
CRT " 1. Insert "
CRT " 2. Display "
CRT " 3. Update"
CRT " 4. Delete”
CRT " 5. Exit”
INPUT Y.CHOICE
Slide 33
More on CRT
Slide 34
Solution
Slide 35
Solution
BEGIN CASE
CASE Y.CHOICE = 1
GOSUB PERFORM.INSERT
CASE Y.CHOICE = 2
GOSUB PERFORM.DISPLAY
CASE Y.CHOICE = 3
GOSUB PERFORM.UPDATE
CASE Y.CHOICE = 4
GOSUB PERFORM.DELETE
CASE Y.CHOICE = 5
EXIT(1)
CASE 1
CRT “Invalid option entered.Exiting..”
EXIT(1)
END CASE
Slide 36
Solution
▪ If choice is 1 (Insert)
▪ Accept the @ID, name, classification, region and courses.delivered
▪ Write the data on to the TRAINER file
Slide 37
Solution
CRT "Enter details to create a new record"
R.TRAINER = '‘
CRT "EMP ID: "
INPUT Y.EMP.ID
Slide 38
Solution
Slide 39
Write the record to the file
Slide 40
Solution
▪ If choice is 2 (Display)
▪ Accept the @ID
▪ Check if the record exists. If it does read the record from the file and display the
record
▪ Syntax
Slide 41
Solution
Slide 42
Solution
▪ If choice is 3 (Update)
▪ Accept the @ID
▪ Check if the record exists. If it does
Read and Lock the record from the file
Accept the changes for the various fields
Write the data on to the TRAINER file
Slide 43
Insight into READ
Slide 44
READU
▪ Use the READU statement when you wish to read and lock a record
▪ Syntax
Slide 45
Insight into READU
Slide 46
READU – When is the lock released
The lock taken by the READU statement will be released by any of the
following events:
Slide 47
More code
Slide 48
Solution
*Only field 4(Courses delivered) needs to be handled differently
IF R.TRAINER<Y.FIELD.NUM> NE 4 THEN
R.TRAINER<Y.FIELD.NUM> = Y.FIELD.VALUE
END
ELSE
R.TRAINER<4> = ‘’ ; *Delete all values in field COURSES.DELIVERED
Y.COUNT = DCOUNT(Y.FIELD.VALUE,',')
FOR Y.COURSES.COUNT = 1 TO Y.COUNT
Y.CD = FIELD(Y.FIELD.VALUE,',',Y.COURSES.COUNT,1)
R.TRAINER<4,-1> = Y.CD
NEXT Y.COURSES.COUNT
END
CRT “Do you wish to update another field”
CRT Y.OPERATION
REPEAT
*Write the new record to the file
WRITE R.TRAINER TO F.TRAINER,Y.EMP.ID SETTING V.ERR.VAR ON ERROR
CRT “Record could not written”
CRT “Reason: “:V.ERR.VAR
END
Slide 49
Solution
▪ If choice is 4 (Delete)
▪ Accept the @ID
▪ Check if the record exists. If it does
Delete the record from the file
▪ Example
DELETE F.TRAINER,Y.EMP.ID SETTING Y.ERR.VAR ON ERROR
END
Slide 50
Take a look at the consolidated solution
Slide 51
Workshop
Once a record id is accepted, a check to see if the record already exists has to take place
If the record id exists
Insert operation should not be permitted
All other operations can be permitted
If the record id does not exist
Insert operation should be permitted
All other operations should not be permitted
Slide 52
Task
Slide 53
Algorithm
Step 1: Edit the dict file TRAINER]D add the field ‘DESIGNATION’
Slide 54
Algorithm
Step 8: If the count is greater than 5, set the field designation to senior
else junior
Step 10: Repeat steps 4 to 9 for all trainers using the loop and repeat
statements
Slide 55
Solution
▪ Edit the dictionary file TRAINER]D and add the field ‘DESIGNATION’
OPEN TRAINER TO F.TRAINER THEN CRT “Open Successful” ELSE CRT “Unable to open file”
Slide 56
Solution
▪ Syntax
▪ Example
Slide 57
Solution
▪ Syntax
▪ Example
Slide 58
Solution
▪ Syntax
▪ Example
DIM Y.MAT.REC(10)
END
Slide 59
Solution
▪ Get the value for the field courses delivered and count the number of
courses delivered
Y.COURSES.DELIVERED = Y.MAT.REC(4)
Y.COUNT = DCOUNT(Y.COURSES.DELIVERED,VM)
Slide 60
Solution
▪ If the count is greater than 5, set the field designation to senior else
junior
IF Y.COUNT GT 5 THEN
Y.MAT.REC(5)<1> = 'SENIOR'
END
ELSE
Y.MAT.REC(5)<1> = 'JUNIOR'
END
Slide 61
Solution
▪ Syntax
▪ Example
Slide 62
Take a look at the consolidated solution
Slide 63
Workshop
Write a program which will check the number of tests passed by the trainee.
If the number is more than 5, then update the field STATUS to
PERMANENT else PROBATION. Use dimensioned arrays in the program.
Use MATREADU to read. Refer the www.jbase.com website for details on the
MATREADU statement.
Slide 64
Variables - Scope
Slide 65
Transaction Management
Slide 66
What Is A Transaction Block?
A cheque to
• Debit Customer A with USD 500
• Credit Customer B with USD 500
Reason : House Rent
Slide 67
What Is A Transaction Block? (Cont.)
A cheque to
• Debit Customer A with USD 500
• Credit Customer B with USD 500
Reason : House Rent
Slide 68
Transaction block in jBASE
TRANSTART
<statements>
<statements>
TRANSEND
Slide 69
Transaction Processing
Slide 70
Workshop
Slide 71
Useful jBASE commands
Slide 72
Quiz
Slide 73
Summary
Slide 74
Summary (Cont.)
Slide 75
Thank You