Hilmas User's Guide | ||
---|---|---|
Back | Language Basics | Next |
To do some arithmetic calculation in Hilmas can be used LET statement.
The syntax is:
LET var,(expression1),op,(expression2),op,(expression3),op,(expression4)....
where:
- var is the result of this calculation
- expressions can be :
- a single variable (of the same type of var) (parentheses are unnecessary)
- a constant (of the same type of var) (parentheses are unnecessary)
- an expression enclosed in parentheses, that is in the form (var1,op,var2), where vars can be variables or constants
- operands op can be only arithmetic operands, that is +,-,*,/
There are some limits in the use of this instruction:
- no operator precedence is considered: reckons are done in the order in which are written
- parentheses are used to modify the order of calculation
- only one level of parentheses are permitted (no nesting of expressions is permitted)
- all the variable must me of the same numeric type
- numeric type permitted are integer (F or H), packed (P) or Float (D)
- divide (/) between integer is always an integer (result is truncated to an integer value)
- no virtual decimal point is considered for packed
For example:
LET J,DDD,-,I,-,MBIS
is the same that in BASIC: LET J = DDD - I - MBIS
LET GG,(DECIM,-,1),/,4,+,(36524,*,SEC),+,(SEC,/,4),+,(DECIM,*,365),+,DDD,+,CGG
If more than one level of parentheses should be required, the order of the operands must be changed to obtain only one level of parenthases.
Logical expressions are a combination of comparisons that produce a logical value: true or false. These expressions can be used only in control statements like IF, WHILE, REPEAT UNTIL and SELECT WHEN. Comparisons can be done between numbers of the same type or between strings; every conmparison can be combined with another using OR or AND logical operators. Generally speaking:
(var1,comp,var2),op,(var3,comp,var4),op,(var5,comp,var6)........
where:
- vars are the compared variables (or constants); var1 must be of the same type of var2, var3 of the same type of var4 and so on
- comp is a comparison operand and can be :
- = equal
- <> not equal
- < less
- > greater
- <= less or equal
- >= greater or equal
- operands op can be :
- OR result value is true if at least one of the operands is true, otherwise is false
- AND result value is true if both the operands are true, otherwise is false
Note that:
- no nesting is permitted, only one level of parentheses is allowed
- comparison between strings is done using the shorter length (where "length" is that defined in DC or DS)
- comparison between strings uses EBCDIC character encoding to decide which is greater
- there isn't any operator precedence between AND and OR, calculation is done in the written order, so you must put the comparisons in the correct order
For example:
IF (SYS,=,'DOS '),AND,(RECNUM,>,10) THEN
. . . . .
SELECT
WHEN (STRING,=,'/F'),AND,(SYS,=,'MVS'),OR,(N,<=,M)
. . . . .
WHILE (RECPROC,=,NOMEPROC) DO
. . . . .
Back | Start | Next |
Data move and Arrays | Top | Control structures |