How to: |
The .EVAL operator enables you to change a procedure dynamically.
[&]&variable.EVAL
where:
Is either local (&) or global (&&).
Consider the following example:
-SET &A = '-TYPE'; &A HELLO
The resulting stack for the above is:
-TYPE HELLO
which generates an error, because it is a Dialogue Manager command, not a server command.
Adding the .EVAL operator to the preceding example enables the server to interpret the amper variable correctly and generate the expected result:
-SET &A = '-TYPE'; &A.EVAL HELLO
The output with the .EVAL operator is:
HELLO
The .EVAL operator is typically used in:
In the following example, the .EVAL operator is used in a record selection test. It forces early substitution of the value for &R (that is, before parsing of the SQL code).
-SET &R = 'WHERE COUNTRY = ' || '''ENGLAND'''; -IF &OPTION EQ 'YES' GOTO START; -SET &R = '-*'; -START SELECT COUNTRY FROM CAR &R.EVAL ; TABLE ON TABLE HOLD END
The next example illustrates the use of the .EVAL operator to perform a calculation. It forces early substitution of the value for &OPER, converting the -SET command to a calculation.
-SET &A = &OPERANDA &OPER.EVAL &OPERANDB; -TYPE &OPERANDA &OPER &OPERANDB IS &A
iWay Software |