Wednesday, September 11, 2019

IF-ELSE, DO, CASE in Easytrieve

IF, ELSE-IF, ELSE & END-IF statements are available in Easytrieve. Relational operators are :

i)  EQ or =
ii) NE or »= or NQ
iii) LT or < or LS
iv) LE or <= or LQ
v) GT or > or GR
vi) GE or >= or GQ

To perform a set of statements n times, DO WHILE or DO UNTIL statement can be used.
Example :
I = 1
DO WHILE I < 10
I = I + 1
END-DO

CASE statement : CASE is similar to EVALUATE statement.

Example :
i)

CASE WS-NUM
WHEN 1
WS-DOB-CC EQ '18'
WHEN 0 2 -> OR need not be coded explicitly
WS-DOB-CC EQ '19'
WHEN 3
WS-DOB-CC EQ '20'
END-CASE

ii)

CASE WORK-GROSS
WHEN 0 THRU 1000
XMAS-BONUS = PAY-GROSS * 1.03
WHEN 1001 THRU 5000
XMAS-BONUS = PAY-GROSS * 1.05
OTHERWISE
XMAS-BONUS = PAY-GROSS * 1.10
END-CASE

No comments:

Post a Comment