basic.logical.expressions Definition/BASIC Program
basic.logical.expressions
| Command | basic.logical.expressions Definition/BASIC Program Applicable release versions: AP, R83 |
|---|---|
| Category | BASIC Program (486) |
| Description | application of logical (Boolean) operators to relational or arithmetic expressions. The result of an operation has two states; "true" and "false". Logical expressions are considered false when equal to zero, and are considered true when non-zero. Logical operators have the lowest precedence and are evaluated after all other operations have been evaluated. If two or more logical operators appear in an expression, the leftmost is performed first. Logical operators act on their associated operands as follows: a OR b is true (evaluates to 1) if a is true or b is true. a ! b is false (evaluates to 0) if a and b are both false. a AND b is true (evaluates to 1) only if both a and b are true. a & b is false (evaluates to 0) if a is false or b is false or both are false. The "not" function negates the effect of a logical expression: not(a or b) is true (evaluates to 1) if a is false or b is false. not(a and b) is true (evaluates to 1) if a and b are false. |
| Syntax | |
| Options | |
| Example | if x then...
The "then" clause is taken when "x" is a non-zero numeric.
Whether x is a numeric constant, or an ASCII string, any non-zero numeric value
of "x" is true.
word = "apple"
chr = word[1,1]
print "A":
print str("n",chr="a" or chr = "e" or chr =
"i" or chr = "o" or chr = "u") :
print " ":word
This prints "An apple", because chr = "a".
visit.date = customer.item<5>
if visit.date then ...
In this example, the "then" clause is executed if
"visit.date" evaluates to a non-zero numeric.
if x > 1 and x < 10 then...
The "then" clause is taken if "x" is between 1 and 10,
exclusive.
if (x > 1 and x < 10) or (x >= 100 and x <= 200) then...
The "then" clause is taken if either "x" is between 1 and
10, exclusive, or between 100 and 200, inclusive.
if not(print.flag = "n") then printer on
The "printer on" statement is executed if the value of
"print.flag" is not "n". |
| Purpose | |
| Related |
data.representation expression basic.relational.operators basic.case string.expressions basic.precedence basic.null basic.boolean.expressions basic.else basic.arithmetic.expressions basic.if basic.search.for.truth basic.and basic.! basic.ifr |
