0% found this document useful (0 votes)
215 views

Infobasic - 1

Uploaded by

Yogish Prince
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
215 views

Infobasic - 1

Uploaded by

Yogish Prince
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 105

Infobasic

Technical Courses
Agenda & Objective
Session-wise plan

 Session – I & II
• Introduction to Infobasic Programming
• Navigation with JED
• Infobasic Programming
 Session – III & IV
• Control structures
• Array

3 Thesys TRAINING Practice


Objective

 At the end of this session, participants will


• Know programming features of Infobasic
• Know the various array types
• Know how to program using various control structures

4 Thesys TRAINING Practice


Infobasic Programming
Why Infobasic?

 Programming language used in T24


 Has simple English like statement

6 Thesys TRAINING Practice


Why Infobasic?

 No variable declaration required


 No data type specification required
 All Variables – Infinite length (By default)
• Multi value
• Sub Value

7 Thesys TRAINING Practice


Navigation
jBASE EDITOR

EDITING NEW
WORKING RECORDS
EDITING
WITH
EXISTING
BLOCKS
RECORDS
DELETING jBASE
TEXT EDITOR STARTING
THE EDITOR
REPLACING
TEXT SAVING AND
MOVING
ADDING EXITING THE
AROUND
TEXT EDITOR
WITHIN THE
EDITOR

9 Thesys TRAINING Practice


Editing Existing Record

JED {DICT} {filename}{record.id}


EDIT THE DICTIONARY OR THE FILE FOR ITEM NAME

10 Thesys TRAINING Practice


Editing New Record

 Different prompt appears, if record is not existing


 Blank Text prompt appears

11 Thesys TRAINING Practice


Editor commands

 Can be entered in both


• Text prompt
• Command prompt

12 Thesys TRAINING Practice


JED commands

 Text Prompt
• Ctrl X -> Exits without saving

13 Thesys TRAINING Practice


JED commands

 Command Prompt
• EX & EXIT -> Exits without saving
• EXK -> Exits from group of records
• FI -> Saves changes
• FS -> Saves changes and resume edit

14 Thesys TRAINING Practice


JED commands – Command Prompt

• BI -> Formats BASIC code


• DE -> Deletes the current line
• R/old/new -> Changes first occurrence of old text to new
text
• RU/old/new -> All old text to new text on the current line

15 Thesys TRAINING Practice


JED commands – Command Prompt

• RU3/old/new -> Changes all occurrences of old text to new text


over the next 3 lines
• ‘L chars’ & ‘/ chars’ -> Locates next occurrence of text (chars)
• Ctrl P -> Locates previous occurrence of text (chars)
• ctrl
n -> To repeat location of text that is located using
the command “L chars”

16 Thesys TRAINING Practice


JED commands – Editor

• ctrl a -> Move cursor to start of current line


• ctrl e -> Move cursor to end of current line
• ctrl W -> Delete word
• ctrl K -> Deletes text till the end of line
• ctrl DD -> Delete the current line

17 Thesys TRAINING Practice


JED commands – Editor

• ctrl L -> Insert new line below current line


• ctrl O -> Toggles between overwrite and insert mode
• ctrl R -> Redisplay screen
• ctrl T -> Copy character from above line to the cursor position

18 Thesys TRAINING Practice


JED commands – Editor

• ctrl V -> Align text in the Editor


• <ENTER> -> new line / breaks current line

1 To go to beginning of Line

9 To go to end of Line
9
nn To go to Line (nn)

19 Thesys TRAINING Practice


JED Navigation

Esc To move b/w Command


Prompt & Text Prompt

Enter To move to Text Prompt from


Command Prompt

20 Thesys TRAINING Practice


Navigation – Within Editor

Up one line

 Down one line

 Right one character

Left one character


21 Thesys TRAINING Practice


Non text-based Commands

 S? -> Displays size in bytes


 ! Command -> Execute jBASE command within editor

22 Thesys TRAINING Practice


Defining and Using Blocks

 From text prompt


• Position the cursor and press
• Ctrl g to define the start and end of a block
 CA -> Copies a block of text after (below) the line on
which cursor is positioned
 CB -> Copies a block of text before the line on which
cursor is positioned

23 Thesys TRAINING Practice


Defining and Using Blocks

 CA4 -> Copies a block of text 4 times after the line on


which cursor is positioned
 CB4 -> Copies a block of text 4 times before the line on
which cursor is positioned
 MA -> Moves a block of text after the line on which
cursor is positioned
 MB -> Moves a block of text before the line on which
cursor is positioned
 DB -> Deletes a block of text

24 Thesys TRAINING Practice


Merging Text

 Position cursor in text prompt, to insert merge line from


another text prompt
 From command line
• !JED filename recordname
 Block (ctrl g) - Lines to be merged
 From command line
• Type –> MERGE
• Press –> Enter Key
 Original record will now have the merged lines

25 Thesys TRAINING Practice


Additional Information

 Block
• Ctrl+g -> To select line from text prompt
• After pasting, paste buffer (or the position of the block) is lost
 Locate
•L -> Locate the 1st word of the text entered
•/ -> Locates the whole text

26 Thesys TRAINING Practice


PATH

 Contains a list of all directories that has executable


programs
 Set to locate system and other application executables (like
C, java, etc)
 Add paths for jBASE and user executables
 User executables are cataloged programs for the Globus
application

27 Thesys TRAINING Practice


PATH

 UNIX
• PATH=$PATH:/apps/bin

• Export PATH
 Windows
• SET PATH=%PATH%;D:\apps\bin

28 Thesys TRAINING Practice


JBCOBJECTLIST

 Shows Search path of user subroutines


 Used during program execution
 Unix
• JBCOBJECTLIST=$HOME/lib:/home/TESTBASE/lib

• export JBCOBJECTLIST
 Windows
• SET JBCOBJECTLIST=%HOME%\lib;C:\dev\TESTBASE\lib
NOTE: All system variables are prefixed with $ in Unix and % in
windows

29 Thesys TRAINING Practice


JBCDEV_BIN AND JBCDEV_LIB

 Define where the locally developed executables and libraries


are stored (when cataloged)
 Tell jBASE where to put your cataloged programs and
subroutines
 These paths should be included in your PATH and
JBCOBJECTLIST for your programs to be used

30 Thesys TRAINING Practice


JBCDEV_BIN AND JBCDEV_LIB

 Export JBCDEV_BIN=$HOME/bin
 Export JBCDEV_LIB =$HOME/bin

31 Thesys TRAINING Practice


Infobasic Programming
Programming Execution

Infobasic Programming

Program Subroutine

Execute in database prompt Execute within Globus

33 Thesys TRAINING Practice


Difference

PROGRAM SUBROUTINE

Executed in jShell prompt Executed in Globus

Can be invoked by itself in Can be invoked only through


jBase program in jBase

Executables stored in .bin Executables stored in .lib

PGM entry not required PGM entry required

34 Thesys TRAINING Practice


Programming flow

 Write Program/Subroutine
 Compile and catalog the Program/Subroutine
 Execute the Program/Subroutine

35 Thesys TRAINING Practice


Structure of Program

*Comments
PROGRAM <Program name>
Statement 1
Statement 2
Statement 3
END

36 Thesys TRAINING Practice


Structure of Subroutine

*Comments
SUBROUTINE <Subroutine name>
Statement 1
Statement 2
Statement 3
RETURN
END

37 Thesys TRAINING Practice


Compilation & Cataloging

 Process of converting source code to object code


 Result of compilation
• File with prefix $ is created and stored in same directory
 Use ‘COMPILE Filename Program/Subroutinename’
 E.g. CATALOG STENI.BP HELLO

38 Thesys TRAINING Practice


Program Compilation

 Process of converting source code into object code


 Use BASIC from jShell prompt
• Example: BASIC XXX.BP TEST.PRG
 On compilation, file prefixed with $ will be created and stored
in same directory
• Example: $TEST.PRG

39 Thesys TRAINING Practice


Program Cataloging

 Process of converting object code into main program


executables
 CATALOG – Command used to catalog from jShell prompt
• Example: CATALOG XXX.BP TEST.PRG
 DECATALOG – Command used to remove object files
• Example: DECATALOG XXX.BP TEST.PRG

40 Thesys TRAINING Practice


Compilation Error

 When error appears at compilation stage


• Solve error in the Program/Subroutine & Compile again
OR
• Use DEBUG in Program/Subroutine, after solving syntax error
• Compile again using ‘EB.COMPILE Filename
Program/Subroutine name –D’

NOTE: DEBUG enables us to view value of variables


(/variable), while running the Program/Subroutine

41 Thesys TRAINING Practice


Solution

 Error appears, when program/subroutine is not compiled

42 Thesys TRAINING Practice


Solution

 Bug in program causes error during compilation


 Solve the error & compile again

43 Thesys TRAINING Practice


Compiling And Cataloguing Routines

44 Thesys TRAINING Practice


Execution

 Program
• Execute in database (jshell) prompt
• Enter Program name in database prompt & press Enter key
 Subroutine
• Execute in Globus prompt
• Log into T24 classical mode
• Enter Subroutine name in Globus prompt & press Enter key
NOTE: For Subroutine execution in Globus prompt, make a
PGM entry of the program with type as M

45 Thesys TRAINING Practice


Executing Programs

46 Thesys TRAINING Practice


Executing Routines

47 Thesys TRAINING Practice


Example

 Write a simple program to display ‘HELLO WORLD’

48 Thesys TRAINING Practice


Solution

 Create a file as shown, to store the program


 Use the command:
CREATE.FILE filename TYPE=UD

49 Thesys TRAINING Practice


Solution

 Type jsh > JED <filename> <programname>


 Enter the code to display ‘HELLO WORLD’
 Type jsh > EB.COMPILE <filename> <programname>

50 Thesys TRAINING Practice


Solution

 Output appears as shown

51 Thesys TRAINING Practice


Example

 Create a routine with parameter, to


• Pass two values and
• Returns multiplication of two values in variable

52 Thesys TRAINING Practice


Solution

 Create a program and a subroutine as shown in the screen


shots

Subroutine called

53 Thesys TRAINING Practice


Solution

 Compile the subroutine

54 Thesys TRAINING Practice


Solution

 Compile the program

55 Thesys TRAINING Practice


Solution

 While running/executing the program the routine is called”


 Resulting, output appears as shown

56 Thesys TRAINING Practice


Control Structures
Control structures

 IF..THEN
 IF..END ELSE..END
 CASE
 FOR
 LOOP WHILE
 LOOP REPEAT

58 Thesys TRAINING Practice


IF..ELSE Structure

IF <condition> THEN
<statements>
END ELSE
<statements>
END

59 Thesys TRAINING Practice


Example

 Write a program to print “No. is greater than 7” else to print


“No. is smaller than 7”

60 Thesys TRAINING Practice


Solution

 Write a program as shown

61 Thesys TRAINING Practice


Solution

 Compile the program as shown

62 Thesys TRAINING Practice


Solution

 Output appears as shown

63 Thesys TRAINING Practice


Nested IF Structure

IF expression THEN
statements
END ELSE
IF expression THEN
statements
END ELSE
statements
END
END

64 Thesys TRAINING Practice


Example

 Write a program to display


• “No. GT 100” – when input number is greater than 100
• “No.GT 50 and LT 100” - when input number is greater than 50
and less than 100
• “No. LT 50” – when input number is less than 50

65 Thesys TRAINING Practice


Solution

66 Thesys TRAINING Practice


Solution

 Compile and run the program


 Output of the Nested-If program appears as shown

67 Thesys TRAINING Practice


CASE Structure

BEGIN CASE
CASE <variable> = <value>
<statements>
CASE <variable> = <value>
<statements>
CASE <variable> = <value>
<statements>
CASE 1
<statements>
END CASE

68 Thesys TRAINING Practice


Control Flow

 Expressions/statements evaluated in sequential order


• When a true expression is encountered,
– Corresponding statements are executed and control exits from the
CASE structure
• When no true expression is encountered,
– Statements under CASE 1 are executed and control exits from
the CASE structure
– In the absence of CASE 1 expression, then no statements are
executed and control exits from the CASE structure

69 Thesys TRAINING Practice


Example

 Write a program to print the name, if the given choice is


equal to (or matches) the first two characters of the given
name, else print the message “No match”

70 Thesys TRAINING Practice


Solution

 Write a program as shown

71 Thesys TRAINING Practice


Solution

 On successful compilation & execution, output appears as


shown

72 Thesys TRAINING Practice


FOR-NEXT Structure

FOR <variable> = <initial value> To <maximum value>


<statements>
NEXT <variablename>

73 Thesys TRAINING Practice


Example

 Write a program to print text ‘Counter Variable’ in loop of 10


times

74 Thesys TRAINING Practice


Solution

 Write a program to print text in loop as shown

75 Thesys TRAINING Practice


Solution

 On successful compilation & execution, output appears in


loop as shown

76 Thesys TRAINING Practice


Workshop

 Write a program to print text ‘Counter Variable’ for a fixed


number of times

77 Thesys TRAINING Practice


Solution

 Write a program as shown: to receive the number of times


the text has to be printed & then form loop to print the text

78 Thesys TRAINING Practice


Solution

 On successful compilation & execution, output of program


appears as shown

79 Thesys TRAINING Practice


Example

 Write a program to print the text “Counter Variable:” followed


by only odd numbers, till 10

80 Thesys TRAINING Practice


Solution

 Write a program to print the text along with odd number, up


to 10

81 Thesys TRAINING Practice


Solution

 Output appears as shown

82 Thesys TRAINING Practice


LOOP-WHILE structure

LOOP <statements>
WHILE/UNTIL <expression>
<statement>
REPEAT

83 Thesys TRAINING Practice


Example

 Write a program to print incremental of numbers, using while


condition

84 Thesys TRAINING Practice


Solution

 Write a program as shown, to print incremental of numbers


less than ‘4’

85 Thesys TRAINING Practice


Solution

 On successful compilation & execution, output of the


program appears as shown

86 Thesys TRAINING Practice


LOOP-REPEAT structure

Loop <statement>
UNTIL <expression>
<statement>
REPEAT

87 Thesys TRAINING Practice


Example

 Write a program to print incremental of numbers, using until


condition

88 Thesys TRAINING Practice


Solution

 Write a program to print number until 4 is reached

89 Thesys TRAINING Practice


Solution

 On successful compilation & execution, output of the


program appears as shown

90 Thesys TRAINING Practice


Difference

LOOP-WHILE LOOP-UNTIL-REPEAT
 Facilitates repeated
 Facilitates repeated execution
execution of a set of
of a set of statements, control
statements, control exits from
exits from structure when
structure when condition
condition evaluates to false
evaluates to true

91 Thesys TRAINING Practice


Array & Its Types
What is an Array?

 Continuous allocation of bytes


 Array bytes – Same name as that of the array
 Each byte – uniquely identified using a subscript

T H E S Y S

1 2 3 4 5 6

93 Thesys TRAINING Practice


Array Types

Array Types

Dynamic Dimensioned
E.g. R.CUSTOMER E.g. ID.NEW

R.CUSTOMER – Holds the currently opened record


ID.NEW – Contains ID of currently opened record

94 Thesys TRAINING Practice


Dynamic Array

 Dynamic in nature
 Variable length
 Need not be declared
 Can hold any type of data
 All variables in Infobasic are dynamic arrays

95 Thesys TRAINING Practice


Dimensioned Array

 Fixed number of rows and columns


 Can hold any type of data
 Needs to be declared
 Used for known and unchanging dimensions and extents

96 Thesys TRAINING Practice


Array Allocation

 Dynamic Array

 Dimensioned Array

97 Thesys TRAINING Practice


How to create Dynamic array?

 Initialization of variable
 Can store any type and any amount of data
 E.g.
• CUSTOMER.CODE = ‘’
• WORKING.BAL =0
• DATE = “110602”

98 Thesys TRAINING Practice


Dynamic array storage

 Uses Delimiters to store data of various fields

ASCII Decimal Description


254 Field Marker
253 Value Marker
252 Sub-value Marker

99 Thesys TRAINING Practice


Dynamic array storage

100 Thesys TRAINING Practice


Dynamic array storage

BOENG2FMBOENGFMBOENGFM7755 E.MARGINAL WAY


SOUTHFMSEATTLEFM4VM100404FM5VM100292

101 Thesys TRAINING Practice


How to create Dimensioned array?

 Use variable DIM ARRAYn(X,Y)


Where,
X – Row
Y – Column
 E.g.
DIM ARRAY1(4,3)
DIM ARRAY2(4)

102 Thesys TRAINING Practice


Dimensioned Array

DIM ARRAY1(4,3)
4 – Rows
3 – Columns

103 Thesys TRAINING Practice


Dimensioned Array

DIM ARRAY2(4)
4 – Rows
Unlimited columns

NOTE: Each row will be a dynamic array

104 Thesys TRAINING Practice


All product names and other company names used herein are for identification purposes only and may be
trademarks or registered trademarks of their respective owners. Errors and omissions excepted,
all specifications are subject to change without notice.

© 2009 Thesys Technologies Incorporated. All rights reserved.

FOR MORE INFORMATION


Visit : www.thesys.co.in
email : [email protected]

You might also like