You can combine several logical expressions together in one single expression by using the logical link operators AND and OR:
- To combine several logical expressions together in one single expression which is true only if
- all of the component expressions are true, link the expressions with AND.
- To combine several logical expressions together in one single expression which is true if at least one of the component expressions is true, link the expressions with OR.
- To negate the result of a logical expression, NOT operator can be used.
Example:
DATA: F TYPE F VALUE '100.00',
N(3) TYPE N VALUE '123',
C(3) TYPE C VALUE '456'.
WRITE 'The following logical expression is true:'.
IF ( C LT N ) AND ( N GT F ).
WRITE: / '(',C,'lt',N,') AND (',N,'gt',F,')'.
ELSE.
WRITE: / '(',C,'ge',N,') OR (',N,'le',F,')'.
ENDIF.
The output is:
The following logical expression is true:
( 456 ge 123 ) OR ( 123 le 1.000000000000000E+02 )
The logical expression in the IF statement is true, and the inverted expression is displayed.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.