Logical expressions determine the path your program logic takes through conditional and looping statements like if, while, for, and case.
The following table summarizes the operators and operands for elementary logical expressions. Elementary expressions consist of an operand, a comparison operator, and a second operand.
First operand | Comparison Operator | Second operand |
---|---|---|
date/time expression | ==, != , <, >, <=, >= | date/time expression The first and second expressions must be of compatible types. See Assignment compatibility in EGL. For date/time comparisons, the greater than sign (>) means later in time; and the less than (<) sign means earlier in time. |
numeric expression | ==, != , <, >, <=, >= | numeric expression |
string expression | ==, != , <, >, <=, >= | string expression |
string expression | like | regular expression A character field or literal that string expression is compared to, character position by character position from left to right. regular expression can contain wildcard and escape characters. |
string expression | matches | regular expression , A character field or literal that string expression is compared to, character position by character position from left to right. regular expression can contain wildcard and escape characters. Regular expression rules differ between the like and the matches operators. |
NUM or CHAR value | ==, != , <, >, <=, >= | NUM or CHAR value |
searchValue | in | arrayName For more information, see in operator. |
variable in basic record |
|
Either:
|
sysVar.systemType |
|
For more information, see systemType. |
record name |
|
An I/O error value appropriate for the record organization. See I/O error values. |
You can use "and" (&&) and "or" operators (||) to build complex expressions by combining pairs of more elementary expressions. In addition, you can use the "not" operator (!) to reverse the value of an expression (changing TRUE to FALSE and FALSE to TRUE).
var01 == var02 || 3 in array03 || x == y
If var01 does not equal var02, evaluation proceeds. If the value 3 is in array03, the overall expression is TRUE, and EGL does not need to evaluate the last elementary logical expression (x == y).
Similarly, if elementary logical expressions are combined by "and" operators, EGL stops the evaluation as soon as one of the elementary logical expressions resolves to FALSE. In the following example, evaluation stops as soon as var01 is found to be unequal to var02:
var01 == var02 && 3 in array03 && x == y
Platform | Issue |
---|---|
COBOL generation | COBOL does not offer a way to compare MBCHAR or DBCHAR to UNICODE or STRING. |
JavaScript generation | The following types are not supported: ArrayDictionary, BIN (with decimal places), BLOB, CHAR, CLOB, DBCHAR, HEX, INTERVAL, MBCHAR, NUMC, STRING (with a size limit), PACF, UNICODE, and structured Record parts. |
VisualAge® Generator compatibility mode | You cannot use is or not to test a value returned by vgLib.getVAGSysType(). |