Using VPLUS: An Introduction to Forms Design (32209-90004)

5-15
Figure 5-11. Field Menu for DISCNT
CONDITIONAL CALCULATIONS
When you press ENTER to record DISCNT_PERCNT, the menu for the next
field, DISCNT, is displayed, as shown in Figure 5-11. The DISCNT field
illustrates a new statement. In most cases, a discount is granted
conditionally. In this exercise, you give the customer a discount only
if the total net value of the order is at least $1,000. Such a discount
can be calculated automatically using the IF statement. The IF state-
ment
causes an operation to be performed only if a specified condition is
true.
Action
First, set the field type of DISCNT to D for display-only and the data
type to NUM2. Then, press FIELD TOGGLE and type the IF statement, as
shown in Figure 5-11; press ENTER.
Assuming that DISCNT_PERCNT is 10, DISCNT is set to 10 percent of any net
total equal to or greater than $1,000. If the net total is less than
$1,000, the ELSE statement is executed to set DISCNT to 0.