Expressions
ANSI
Expressions used with structured code are a way of altering program flow based on a certain condition (or conditions) being evaluated and found true. This allows replacement of many PL/B instructions with code that is more efficient and easier to read. Expressions may be used anywhere a numeric variable is normally used. Operators allowed within expressions are:
|
Expression |
Meaning |
|
= or == |
Operand 1 is equal to the operand 2. |
|
!= |
Operand 1 is not equal to the operand 2. |
|
> |
Operand 1 is greater than operand 2. |
|
< |
Operand 1 is less than operand 2. |
|
>= |
Operand 1 is greater than or equal to operand 2. |
|
<= |
Operand 1 is less than or equal to operand 2. |
|
<> |
Operand 1 is less than or greater than operand 2. Equivalent to the != condition. |
|
| or || |
Logical OR - If any of the expressions are TRUE, the result is TRUE. The word “or” may be used. |
|
& or && |
Logical AND - If all of the expressions are TRUE, the result is TRUE. The word “and” may be used.nu |
|
! |
Logical NOT - Reverses the TRUE or FALSE sense of an expression. Must immediately precede the expression. The word “not” may be used. |
|
LIKE |
The LIKE operator performs a pattern matching string comparison of Operand1 against the Operand2 pattern. The Operand2 string can contain the following pattern characters:
'_' - Underscore character matches any one character. '%' - Percent character matches zero or more characters. '\' - Backslash character is the forcing character that forces the comparison of the next character regardless of the character value. |
|
NOCASE |
The NOCASE is a unary operator that eliminates the case sensitivity when comparing each character of the left operand to the characters in the right operand in a string expression. The NOCASE operator is ignored for any numeric expression operations. |
The entire expression must be enclosed within parentheses. As many as fifty (50) conditions can be evaluated and the precedence can be altered by using additional parentheses within the expression. If additional parentheses are not used, the expression is evaluated from left to right unless both 'and' (&) and 'or' (|) conditions exist. In this case, the and (&) conditions are evaluated first and the result is applied to the remainder of the expression. It is advisable to use additional parentheses (even though it may not be necessary) to aid in understanding of the program logic. If expressions contain CALC style logic within them, they are evaluated in the same manner as the CALC instruction.
String expressions involving DIM strings use the logical contents of the variable from the Form Pointer to the Logical Length.
When using string expressions, the characters of '_', '%' and '\' are treated as normal characters for all string operators except as described for the Operand2 of the LIKE operator.
Condition Flags and Function Keys may be used in expressions.
Note in the examples below spaces are not necessary for evaluation of the expressions. However, it does aid in reading the program and understanding the logic. See the examples below for further information.
Expression examples:
|
|
|
|
TRUE when the value in 'A' is equal to the value in 'B'.
|
|
|
|
FALSE when the value in 'A' is equal to the value in 'B'.
|
|
|
|
TRUE if 'A' is not equal to zero.
|
|
|
|
or
|
|
|
|
TRUE if 'A' or 'B' is not equal to zero.
|
|
|
|
or
|
|
|
|
TRUE if the value in 'A' is equal to the value in 'B' or if the value in 'C' is equal to the value in 'D'.
|
|
|
|
|
|
|
|
|
|
|
|
TRUE if any of the three sub-expressions are true. That is, if 'A' equals 'B', or 'C' equals 'D' and 'E' equals 'F', or 'G' equals 'H'. These two expressions are diagnosed in the same manner. with no additional parentheses given, the first condition evaluated is the and (&) condition.
|
|
|
|
|
|
|
|
TRUE if any of the two sub-expressions are true. That is if 'A' equals 'B' and 'C' equals 'D' or if 'E' equals 'F' and 'G' equals 'H'. These two expressions are diagnosed in the same manner. with no additional parentheses given, the first conditions evaluated are the two and (&) conditions.
|
|
|
|
TRUE if the result of dividing 'NUMBER' by 10 is equal to 100.
|
|
|
|
TRUE if the result of dividing 'NUMB' by 10 is equal to 100 or 150.
|
|
|
|
TRUE if 'A' is less than 100 and greater than 0.
|
|
|
|
TRUE if 'ANS' is equal to Y or N.
|
|
|
|
|
|
|
|
|
|
|
|
Evaluated as TRUE.
|
|
|
|
|
|
|
|
TRUE if the result of multiplying 'B' times 2 and adding 'A' is greater than 10. As above, these two expressions are functionally equivalent.
|
|
|
|
TRUE if the result of adding 'A' to 'B' is not equal to 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The above examples show the use of the NOCASE operator in expressions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The above examples show the use of the LIKE and NOCASE operators in expressions.
See Also: Program Control Instructions
![]() |