Conditional Expression

From BR Wiki
Jump to navigation Jump to search
conditional expression
<number> <comparison operator> <number>
|<numeric expression> <comparison operator> <numeric expression>
|<numeric expression> <comparison operator> <numeric expression> {AND|OR} <conditional expression>
|<string expression> <comparison operator> <string expression>
|<string expression><comparison operator><string expression> {AND|OR} [NOT]<string expression><comparison operator><string expression>}

Conditional expressions evaluate to a boolean numerical value where zero is regarded as false and non-zero is regarded as true. Parentheses, of course, are significant and affect the order of processing. Additional parentheses (properly specified) can be used for visual clarity with no affect on performance.

The "conditional expression" or "cond-expr" parameter is used mainly in IF statements and SKIP commands, although it is also one type of numeric expression. The cond-expr is a comparison of values using one of the following comparison operators (a statement such as IF A THEN GOTO 100 contains an implied comparison of IF A<>0):

<>, >< Not equal to
<=, =< Less than or equal to
>=, => Greater than or equal to
==, = Equal to
> Greater than
< Less than
~ Not
~= Not equal to

AND, OR and NOT may also be used. The use of the colon-equal (:=) symbol to indicate assignment may be unfamiliar to many programmers. Use of this symbol can help reduce program space in some instances. For example, the first of the following statements (using the colon-equal assignment operator) is equivalent to the two statements, which follow it:

00010 PRINT STR$(L:=L+1)
00020 LET L=L+1
00030 PRINT STR$(L)

Business Rules evaluates all conditional expressions to a value of nonzero (true) or zero (false). A true evaluation leads to the THEN action in an IF statement or causes the SKIP action to occur in a SKIP command. A false evaluation leads to the ELSE action in IF statements or prevents the SKIP action from occurring.

See the IF statement for more information.