IF...THEN...ELSE statement
- Last Updated: October 16, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Makes the execution of a statement or block of statements conditional. If
the value of the expression following the IF statement is TRUE, the AVM
processes the statements following the THEN statement. Otherwise, the AVM
processes the statements following the ELSE statement.
Syntax
|
- expression
- A constant, field name, variable name, or expression whose value is logical (TRUE or FALSE). The expression can include comparisons, logical operators, and parentheses.
- THEN
- Describes the block statement to process if the expression is TRUE.
- block
- The block statement that contains the code you want to process if
expression is TRUE. See the DO statement, FOR statement, and REPEAT statement reference
entries for more information. If you do not start a block, you can process just one
statement after the IF keyword or the ELSE keyword.
Any block or blocks you use in an
IF...THEN...ELSEstatement can contain other blocks or otherIF...THEN...ELSEstatements. - statement
- A single ABL statement. The statement can be another
IF...THEN...ELSEstatement. If you want to use more than one statement, enclose those statements in aDO,FOR EACH, orREPEATblock. - ELSE
- Describes the block statement to process if the expression is FALSE or the Unknown value (
?). TheELSEoption is not required.
Example
The r-ifelss.p procedure creates a report in a file that lists Customers whose Orders have been shipped, but who have not paid for those Orders:
r-ifelss.p
|
First, the procedure writes report headers to the ovrdue.lst file. Next, the outer FOR EACH block reads each of
the Orders using a DISPLAY statement to display information on each Order.
If there are no values in the ShipDate and PromiseDate fields, the procedure prompts you to enter a promise
date. The procedure then prompts if the order has been shipped. If it has, supply a ship
date.
If there is a ship date and a promise date for an order, the procedure prompts if the order has been paid for. If not, the procedure displays the order information to the file.