Page 21-32
Activation of the CHOOSE function will return either a zero, if a @CANCEL action
is used, or, if a choice is made, the choice selected (e.g., v) and the number 1,
i.e., in the RPN stack:
Example 1
– Manning’s equation for calculating the velocity in an open
channel flow includes a coefficient, C
u
, which depends on the system of units
used. If using the S.I. (Systeme International), C
u
= 1.0, while if using the E.S.
(English System), C
u
= 1.486. The following program uses a choose box to let
the user select the value of C
u
by selecting the system of units. Save it into
variable CHP1 (CHoose Program 1):
« “Units coefficient” { { “S.I. units” 1}
{ “E.S. units” 1.486} } 1 CHOOSE »
Running this program (press @CHP1) shows the following choose box:
Depending on whether you select
S.I. units or E.S. units, function
CHOOSE places either a value of 1 or a value of 1.486 in stack level 2 and a
1 in level 1. If you cancel the choose box, CHOICE returns a zero (0).
The values returned by function CHOOSE can be operated upon by other
program commands as shown in the modified program CHP2:
« “Units coefficient” { { “S.I. units” 1} { “E.S. units”
1.486} } 1 CHOOSE IF THEN “Cu” TAG ELSE “Operation
cancelled” MSGBOX END »
The commands after the CHOOSE function in this new program indicate a
decision based on the value of stack level 1 through the IF-THEN-ELSE-END
construct. If the value in stack level 1 is 1, the commands “Cu” TAG will
produced a tagged result in the screen. If the value in stack level 1 is zero, the
2: v
1: 1