Expressions
Expressions are a way to express program logic using free-form syntax. They can be used to write program statements in a more readable or concise manner than fixed-form statements.
An expression is simply a group of operands and operations. For example,
the following are valid expressions:
A+B*21
STRINGA + STRINGB
D = %ELEM(ARRAYNAME)
*IN01 OR (BALANCE > LIMIT)
SUM + TOTAL(ARRAY:%ELEM(ARRAY))
'The tax rate is ' + %editc(tax : 'A') + '%.'
Expressions may be coded in the following statements:
- CALLP (Call a Prototyped Procedure or Program)
- CHAIN (Random Retrieval from a File) (free-form calculations only)
- CLEAR (Clear)(free-form calculations only)
- DELETE (Delete Record) (free-form calculations only)
- DSPLY (Display Message)(free-form calculations only)
- DOU (Do Until)
- DOW (Do While)
- EVAL (Evaluate expression)
- EVALR (Evaluate expression, right adjust)
- EVAL-CORR (Assign corresponding subfields)
- FOR (For)
- IF (If)
- RETURN (Return to Caller)
- READE (Read Equal Key) (free-form calculations only)
- READPE (Read Prior Equal) (free-form calculations only)
- SETGT (Set Greater Than) (free-form calculations only)
- SETLL (Set Lower Limit) (free-form calculations only)
- SORTA (Sort an Array)
- WHEN (When True Then Select)
- XML-INTO (Parse an XML Document into a Variable)
- XML-SAX (Parse an XML Document)
Figure 1 shows several examples of how expressions can be used: