Useful functions of T24
Slide 1
OBJECTIVE
After completing this lesson, you should
be able to:
Useful functions in infobasic.
T24 file handling.
Subroutine debugging.
S
Functions in Infobasic
Functions in Infobasic
INPUT
To Accept a Value for a Variable From User
SYNTAX
INPUT VARIABLE
EXAMPLE
INPUT NAME
LEN
Returns the number of Characters in a string
SYNTAX LEN(string)
Example
CRT LEN(‘FDSLTD’)
Output : 6
CALL
The CALL statement executes another program
(optionally passing in arguments to it) and then
resumes execution of the current program.
SYNTAX
CALL name [ ( arg1 [, arg2...)] [RETURNS variable]
EXAMPLE IN TAFJ
CALL TEST.SUB()
LOCATE
Used to search a string in a dynamic array and get it’s position .
Returns the field Position only.
SYNAX
LOCATE <string> IN <array> {<field pos,multivalue pos>} SETTING <var>
THEN/ELSE <statements>
EXAMPLE
DAYS =
SAT’:@FM:’SUN’:@FM:’MON’:@FM:’TU’:@FM:’WED’:@FM:’THU’:@F
M:’FR’
LOCATE "SUN" IN DAYS SETTING FOUND ELSE FOUND = 0
Output: FOUND = 2
FINDSTR
Used to search a string in a dynamic array and get it’s position .
Returns the field Position only.
SYNAX
FINDSTR expression1 IN Var1 {, expression2} SETTING Var2 {,Var3 {,
Var4}} THEN | ELSE statement(s)
EXAMPLE
V.ARRAY = 'ABC' :@FM: 'DEF' :@VM: 'XYZ'
FINDSTR 'XY' IN V.ARRAY SETTING V.FLD, V.VAL THEN
CRT "FIELD: " : V.FLD, "POSITION: ": V.VAL
END
ELSE
CRT "NOT FOUND"
END
Output: FIELD: 2 POSITION: 2
MOD
The MOD function returns the arithmetic modulo of
two numeric expressions.
SYNTAX
MOD(expr1, expr2)
Both expr1 and expre2 should evaluate to numeric
expressions or a runtime error will occur.
EXAMPLE
MOD ( 120, 90 )
OUTPUT 30
SUM
The SUM function sums numeric elements in a
dynamic array.
SYNTAX:
SUM(expr)
EXAMPLE
Y.DATA = 2:@FM:4:@FM:6:@FM:8
CRT SUM(Y.DATA)
Output: 20
SORT
The SORT function sorts all elements of a dynamic array in
ascending left-justified order.
SYNTAX
SORT(expression)
expression may evaluate to any data type but will only be useful if it
evaluates to a dynamic array.
EXAMPLE
MYARRAY ='GEORGE':@VM:'FRED':@VM:'JOHN':@SVM:'ANDY'
CRT SORT (MYARRAY )
OUTPUT ANDY^FRED^GEORGE^JOHN
WHY NEED LOCAL FIELD
Not all fields required by a bank are
available in a T24 application
User defined, totally customisation
Once created, can be reused in various
applications
LOCAL TABLE APPLICATION IMPOTENT FIELD
ID is numeric Description
Holds a description of the field Short Name
Name that is displayed for that field Maximum Char
Maximum number of characters that the field can
hold Minimum Char
If entered, the field becomes a mandatory field in the
application Char Type
Type of data that can be input in this field Vetting
Table
List of predefined values the field can hold Remark
Enrichment for items in the vetting table
LOCAL TABLE APPLICATION IMPOTENT FIELD
ID is the T24 application that the local reference field
is going to be attached to. Local Table No.
The ID of the LOCAL.TABLE Sub Associate Code
Must be used if the local reference field is a multi
value or an associated multi value
XX. Multi Value
XX< Start of an associated multi value set
XX- Part of an associated multi value set
XX> End of the associated multi value set
CREATE LOCAL FIELD
STEP 1. Go to Local table by using this command
“ LOCAL.TABLE I LOCAL_FIELD_NAME”
STEP 2.
STEP 3. Then Commit this page.
ADD LOCAL FIELD TO LOCAL.REF.TABLE
STEP 4. Add this field in a application
STEP 5. Go to Local Ref Table by using this command
“LOCAL.REF.TABLE I”
STEP 6.
STEP 7. Then Commit this page.
After adding local field to CUSTOMER
GetLocRef & MapLocalFields
EB.LocalReferences and EB.Foundation packages are used to
get the local field position for local field.
Return the local reference position
SYNTAX
EB.LocalReferences.GetLocRef(FILE.NAME,LOCAL.FIELD.NAM
,FIELD.POSITN) –This function for single field
EB.Foundation.MapLocalFields(APPLICATION.NAMES,
LOCAL.FIELDS, FLD.POS) –this function for multi field at a time
FIELD.POSITION return the local reference position of an file
according to the respective local field name.
LOCAL FIELD SEARCH
EXAMPLE IN TAFJ
SUBROUTINE LT.EXAMPLE
$INSERT I_COMMON
$INSERT I_EQUATE
$USING EB.DataAccess
$USING EB.Updates
$USING EB.LocalReferences
FN.CUS = 'F.CUSTOMER'
F.CUS = '‘; Y.FLD.POS = '‘
APPLICATION.NAMES = 'CUSTOMER'
LOCAL.FIELDS = 'FATHER.NAME':VM:'MOTHER.NAME'
EB.Foundation.MapLocalFields(APPLICATION.NAMES, LOCAL.FIELDS, FLD.POS)
EB.LocalReferences.GetLocRef(APPLICATION.NAMES, LOCAL.FIELDS, FLD.POS)
/for single field
Y.FATHER.NAME.POS = FLD.POS<1,1>
Y.MOTHER.NAME.POS = FLD.POS<1,2>
LOCAL FIELD SEARCH
EB.DataAccess.Opf(FN.CUSTOMER, F.CUSTOMER)
EB.DataAccess.FRead(FN.CUSTOMER, CUSTOMER.ID, R.CUS, F.CUSTOMER, ERR)
FATHER.NAME = R.CUS<ST.Customer.Customer.EbCusLocalRef,Y.FATHER.NAME.POS>
MOTHER.NAME = R.CUS<ST.Customer.Customer.EbCusLocalRef,Y.MOTHER.NAME.POS>
RETURN
END
LEFT & RIGHT
The LEFT function extracts a sub-string of a specified
length from the beginning of a string.
The RIGHT function extracts a sub-string of a
specified length from the ending of a string.
SYNTAX :
LEFT(expr, length)
RIGHT(expr, length)
EXAMPLE
PRINT LEFT("ABCDEFGH",3)
PRINT RIGHT("ABCDEFGH",3)
Output : ABC Output : FGH
FIELD
Extracts a sub-string from a Character string using
delimiters.
SYNTAX
FIELD(string,delimiter,occur,fields )
EXAMPLE
X = “A/B/C/D”
Y = FIELD(X,”/”,2,2)
RESULT : Y has a value of B/C
INDEX
Returns the starting column position of a specific occurrence
of a specified sub string within a character string.
SYNTAX:
INDEX(string,sub string,occur)
EXAMPLE
A = ‘IPDC LTD’
B = INDEX(A,”LT”,2)
B returns the value 5
ALPHA
Used to determine whether the expression is Alphabet or Not. If
the expression contains any special characters or numeric value
it evaluates false else true.
SYNTAX: OUTPUT
CRT ALPHA(‘ABCDEF’) 1
CRT ALPHA(‘10ABCDEF’) 0
CRT ALPHA(‘ABC DEF’) 0
SEQ
This function returns the ASCII value for a given character.
SYNTAX
SEQ(expr)
Example
SEQ(“A”) returns 65
ABS
Returns the mathematical absolute of the
()expression
expression can be of any form that should evaluate to
a numeric.
SYNTAX:
ABS (expression)
EXAMPLE
CRT ABS (10-15)
Output: 5
COUNT
This function returns the number of times a sub-string occurred
in a string.
SYNTAX
COUNT(expr)
EXAMPLE
A=‘FDSLTD’
CRT COUNT(D,’A’)
Output : 2
DCOUNT
Returns the number of sub-strings delimited by a specified
delimiter in a string value.
Used to find number of values in field.
SYMTAX
DCOUNT(DYNAMIC.ARRAY,DELIMETER)
EXAMPLE
REC=34:@VM:55:@VM:88
R=DCOUNT(REC,@VM)
Result : R has a Value of 3
MAXIMUM & MINIMUM
MAXIMUM Returns the element with the highest numeric Value in a
given Dynamic array.
MINUMUM Returns the element with the lowest numeric value in a
given Dynamic array
SYNTAX:
MAXIMUM(dynamic.array.name)
MINIMUM(dynamic.array.name)
EXAMPLE
Y.DATA = 2:@FM:4:@FM:6:@FM:8
CRT MAXIMUM(Y.DATA)
CRT MINIMUM(Y.DATA)
Output: 8 2
Cdd()
Defined in EB.API package
Calculates the difference, in days, between two supplied date
SYNTAX
EB.API.Cdd(REGION, DATE1, DATE2, DAYS)
REGION Region code
DATE1 Start date, YYYYMMDD
DATE2 End date, YYYYMMDD
DAYS 'W' to indicate working days
'C' to indicate calendar days
DAYS Return the number of days difference
EXAMPLE
=================
EXAMPLE(TAFJ):
$INSERT I_COMMON
$INSERT I_EQUATE
$USING EB.API
Y.START.DATE = '20171001‘
Y.END.DATE = '20171030‘
Y.DAYS = 'C‘
EB.API.Cdd('', Y.START.DATE, Y.END.DATE, Y.DAYS)
OUPTPUT : 29
Cdt()
Defined in EB.API package
Calculates forward or previous date from a start date using the
number of days.
SYNTAX
EB.API.Cdt(REGION, DATE, DAYS)
REGION Region code
DATE1 Start date, YYYYMMDD
DATE2 End date, YYYYMMDD
DAYS 'W' to indicate working days
'C' to indicate calendar days
DAYS The number of days difference, + or -
EXAMPLE
EXAMPLE(TAFJ):
Y.DATE = '20171114‘
Y.DAYS = '+1W‘
EB.API.Cdt('', Y.DATE, '+1W')
PRINT "DATE: ":Y.DATE
OUTPUT: Date: 20171115
ICONV
Converts entered data into internal format onto the disk.
SYNTAX:
ICONV(string,conversion code)
EXAMPLE
CALL ICONV('20150616', 'D')
Output: 17334
ICONV
OCONV
Converts internal format data into format specified.
SYNTAX:
OCONV(string,conversion code)
EXAMPLE
Y.DATE = ‘17334’
CRT OCONV(Y.DATE, 'D')
OUTPUT: 16 JUN 2015
OCONV
Juldate()
Defined in EB.API package
Convert from Julian to Gregorian date format and vice versa
SYNTAX
EB.API.Juldate (GREGORIAN.DATE,JULIAN.DATE)
GREGORIAN.DATE Standard T24 Date in the format yyyymmdd
JULIAN.DATE Julian Date in the format yyyyjjj
EXAMPLE
Gregorian to Julian
Y.GD = ‘’
Y.JD = ‘2014001’
CALL JULDATE(Y.GD,Y.JD)
OUTPUT Y.GD = 20140101
EXAMPLE
Julian to Gregorian
Y.GD = ‘20140101’
Y.JD = ‘’
EB.API.Juldate(Y.GD,Y.JD) OUTPUT Y.JD =
2014001
UPCASE & DOWNCASE
UPCASE converts all lowercase characters in an
expression to uppercase characters.
DOWNCASE converts all uppercase characters in an
expression to lowercase characters.
SYNTAX
UPCASE(exp)
DOWNCASE(exp)
EXAMPLE
UPCASE(‘aaaaaa’) RETURN AAAAAA
DOWNCASE(‘AAAAAA’) RETURN aaaaaa
DROUND
The DROUND function performs double-precision rounding on a
value. Double-precision rounding uses two words to store a number,
accommodating a larger number than in single-precision rounding,
which stores each number in a single word.
SYNTAX
DROUND(val.expr [,precision.expr])
- val.expr Specifies the value to round.
- precision.expr Specifies the precision for the rounding. The valid
range is 0 to 14. Default precision is four places.
EXAMPLE:
A= DROUND(3.14223,2)
OUTPUT A = 3.14
CHANGE
The CHANGE statement operates on a variable and
replaces all occurrences of one string with another.
SYNTAX
CHANGE expression1 TO expression2 IN variable
expression1 - may evaluate to any result and is the
string of characters that will be replaced.
expression2 - may also evaluate to any result and is the
string of characters that will replace expression1 - The
variable may be any previously assigned variable in the
program
EXAMPLE
EXAMPLE
String1 = "Jim“ String2 = "James"
Variable = "Pick up the tab Jim"
CHANGE String1 TO String2 IN Variable
OUTPUT Variable = Pick up the tab James
SUMMARY
- You should now understand about T24 useful functions.
We have explain some command that helps the
programmer to write program frequently.
Thank You!
Questions / Discussion
Slide 45