Slide 6 of 80
Notes:
- Expressions are expected naturally in five CI command (CALC, IF, ELSEIF, SETVAR and WHILE), but they must be forced to be evaluated in the remaining CI commands. This forcing is done by enclosing the expression inside square brackets with a leading “!”.
- A powerful feature of CI expression evaluation is what is called “partial evaluation”. Most programming languages support this concept, which is, performing the minimum level of evaluation needed to determine if a boolean expression is true or false. Not only does this allow the CI to evaluate expressions more efficiently, it is necessary for some compound expressions. For example, consider the following expression: if FALSE and lft(input(“OK to continue?”),1) = “y” then …If the CI had to evaluate the entire expression then the user would see the prompt and be required to enter input. Clearly this is not desirable since the expression will be FALSE regardless of the user input, and the user should not be bothered with the prompt. To my knowledge, MPEX does not support partial evaluation with respect to the existence of not of variables. That is, in a statement like:
if TRUE or lft(varA,1) = "" then ...
MPEX evaluates the expression and enforces that "varA" exists, even though the TRUE clause could halt the left-to-right evaluation. Thus, CI scripts written to exploit partial evaluation may not work in an MPEX environment.
- As will be seen in the examples at the end of this presentation, some expressions can be long and complex. The motivation for writing expressions this way is purely performance, and sometimes hinders support of the script.