Overview | Statement List | Example 1 | Example 2 | Example 3
CHOOSE/string list,[DEFLT,n,][,ALTACT,'message',]response
This statement creates a menu of options which is displayed in a dialog box. One option may be chosen from the menu. The option you choose causes a numerical value to be assigned to a variable, called the response variable. This value may be used later in the program. The most common use is with a JUMP statement. This technique allows you to perform different operations in your program (by jumping to different labels based on the user response) based upon the option chosen from the menu created by the CHOOSE statement.
CAUTION: We do not recommend using the asterisk character (*) in menu prompts or
menu options.
The CHOOSE statement works with the Back, Cancel and the alternate action option within Unigraphics.Back causes the value of 1 to be assigned to the response variable. Cancel causes 2 to be assigned. The value 3 is not used, and may not be used. The alternate action option causes 4 to be assigned to the response variable.
You can create an alternate action option by using the minor word ALTACT, followed by a message, as the parameter just before the response variable. The ALTACT message displays as the last option in the dialog box. You can create messages up to forty characters long.
NOTE: To create a menu of options which allows you to choose multiple
options, use the MCHOOS statement
described later in this section.
The response values 1 through 4 are reserved for the Back, Cancel, and the alternate action option. Therefore, the first value available from the menu options is 5. The first option on the created menu returns 5, the second option returns 6, the third, 7, and so on. There is a maximum of fourteen options on a menu. The following list shows the values that may be assigned to the response variable according to which option is chosen:
Options |
Value |
Back |
1 |
Cancel |
2 |
Not used |
3 |
Alternate Action |
4 |
Option #1 |
5 |
Option #2 |
6 |
. |
. |
. |
. |
Option #14 |
18 |
NOTE: If you want to create a long menu (fourteen options), you
may exceed the maximum character limit for a GRIP statement. Therefore, you may
want to assign the text that makes up the menu options to variables. The menu
can even be created by an array. For example:
STRING/ST(14,40)
ST(1)='Option
1'
ST(2)='Option 2'
ST(3)='Option 3'
ST(4)='Option 4'
ST(5)='Option
5'
ST(6)='Option 6'
ST(7)='Option 7'
ST(8)='Option 8'
ST(9)='Option
9'
ST(10)='Option 10'
ST(11)='Option 11'
ST(12)='Option
12'
ST(13)='Option 13'
ST(14)='Option 14'
CHOOSE/'CHOOSE
OPTION',ST,RSP
JUMP/RJ:,TM:,,,L1:,L2:,L3:,L4:,L5:,L6:,L7:,$
L8:,L9:,L10:,L11:,L12:,L13:,L14:,RSP
The CHOOSE statement above creates the following cue line and dialog box:
An Example of the Menu Created from the CHOOSE Statement
Parameter |
Description |
string list |
A list of strings or string variables which constitute the CHOOSE menu. The first parameter in the list is the message which is covered in the beginning of this section and the remaining parameters in the list are used as options. Each string can contain up to 40 characters.
|
DEFLT |
Minor word that indicates that a menu default position is desired. |
n |
The item number in the menu where the default caret is displayed. |
ALTACT |
Minor word that indicates that an alternate action message is created as the last option in the dialog box. If the alternate action option is chosen, the response variable equals 4. |
'message' |
A string or string variable which represents the alternate action message. The string can contain up to forty characters. |
response |
A variable which is assigned a numerical value based on the user response. |