A SERVICE OF

logo

740 Appendix B
Expression Evaluator Functions
Expression Evaluator Features
Functions may be nested and mixed. String, numeric, and Boolean operations may not,
however, be mixed. For example:
calc 1+'abc'
ERROR
calc 'a' +len('abc')
ERROR
if bound(a) + 3>2 then
ERROR
setvar bool1 true
if bool1 and (str('abc',2,len('ab'))='bc') then
EXPRESSION IS TRUE
endif
calc 'a'+chr(65)
aA
calc 1=3 or 'a' <> 'b'
TRUE
calc chr(ord('A'))
A
calc 2+len(str(lft('abcdefg',2*2),5-3,ord('A')-63))
4, $4, %4
Variables may be used in expressions either through explicit dereferencing or implicit
dereferencing. To explicitly dereference a variable, precede the variable name with an
exclamation point (!). This is passed through string substitution the same as any other CI
command. Explicit dereferencing is recursive, meaning that if the contents of the variable
references another variable (introduced with an exclamation point) the value of the
included variable is also retrieved.
To implicitly dereference a variable, simply use its name in any expression. If a variable
with this name has not been deļ¬ned an error results. Implicit dereferencing is not
recursive. This means that if the contents of an implicitly dereferenced variable contains a
string which might be a variable name, preceded by an exclamation point the evaluator
does not attempt to dereference that variable. Instead, the string value is used in the
expression.
For example:
setvar a 'x'
showvar a
A = x
calc a+'b'
xb
setvar a ''
showvar a
A =
if a = '' then
EXPRESSION IS TRUE
endif
setvar a 'x'
setvar b a
calc a+b
xx
setvar exp 'a+b*c/d'
setvar a 1
setvar b 2
setvar c 3
setvar d 4
setvar e 5
calc exp