Simple Logical Operators Explained
The simple logical operators compare two values (numeric or character) and return a TRUE condition if the logical test is true and a FALSE condition if the result is false. Logical tests can be combined with parentheses and arithmetic operators to perform complex logical comparisons. These operators have two alternate names, one a mnemonic, and the other a mathematical symbol.
|Mnemonic||Mathmatical||Simple Logicla Operator|
|LE||<=||Less Than or Equal To|
|GE||>=||Greater Than or Equal To|
|Not Less Than|
|Not Greater Than|
|or <> Not Equal To|
The logical not symbol (¬) used above is hexadecimal 5f. It may be used with the mathematical symbols for less than (<), greater than (>), and equal to (=).
Following are examples of simple logical operators used in an expression in a the 4GL command:
select salary gt 20000
list by dept where location eq 'nyc'
if salary le 5000 then print empname
Rules for Comparing Notavailable Values
• If a notavailable is compared to another notavailable for equality in a logical expression, the result is TRUE.
• If a notavailable is compared to any other value, the result is FALSE. However, if NE is used in the expression, the result is TRUE.
Special Logical Operators
The special logical operators compare one value with a number of values and return a logical value (TRUE / FALSE) based on whether certain conditions are true or false. These operators allow complicated logical expressions to be stated more simply than could be done with the simple logical operators above.
Compares the value of an expression to a list of values trying to find a matching entry.
Compares an expression to two other expressions to determine if the value of the first expression is between the values of the other two expressions.
Compares the value of a character string expression to each entry in a list of character expressions and indicates whether the first string of characters is contained in the second string.
Compares the value of a character string to a specified pattern and indicates whether the first string of characters matches the pattern. Wild card characters can be included in the pattern.
Each of these logical operators is discussed in detail in Operators Used in Expressions in Chapter 5 of the UltraQuest and NOMAD Reference Manual.