IF THEN ELSE Operations [ HP ALLBASE/BRW Reference Manual ] MPE/iX 5.0 Documentation
HP ALLBASE/BRW Reference Manual
IF THEN ELSE Operations
You can use the construction IF THEN ELSE in a calculation formula to
allow different calculations to be used, depending on whether a condition
is true or false.
Example
Suppose in your report you want to show the discounted amount for an
invoice. The discount for amounts under $1000 is 3 percent, the discount
for amounts over $1000 but under $10,000 is 5 percent, and the discount
for all other amounts is 10 percent. Here is an example of how to use an
IF THEN ELSE operation to calculate the DISCOUNT-AMOUNT:
IF amount < 1000
THEN amount * 0.03 <<3% discount>>>
ELSE IF amount < 10000
THEN amount * 0.05 <<5% discount>>>
ELSE amount * 0.10 <<10% discount>>>
Or, in a shorter form:
amount * (IF amount < 1000 THEN 0.03
ELSE IF amount < 10000 THEN 0.05 ELSE 0.10)
Note that the form is always IF THEN ELSE, and ELSE is required. You can
nest IF THEN ELSE constructions, as shown in the first example.
Related Sections
* Arguments
* List Operations
* Types
MPE/iX 5.0 Documentation