This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
howtos:toolcoding:user_interaction [2010/09/18 17:53] marcus.williams |
howtos:toolcoding:user_interaction [2013/09/12 20:16] (current) deryn.crockett [Menu Command] |
||
---|---|---|---|
Line 18: | Line 18: | ||
//TOOL variable// is the variable into which the entered data is placed. If this is an integer variable, only an integer value can be entered. If this is a boolean variable, the possible values that can be entered are {yes, y, true, 1} or {no, n, false, 0}. These can also be entered as upper case letters. | //TOOL variable// is the variable into which the entered data is placed. If this is an integer variable, only an integer value can be entered. If this is a boolean variable, the possible values that can be entered are {yes, y, true, 1} or {no, n, false, 0}. These can also be entered as upper case letters. | ||
- | |||
==== Example ==== | ==== Example ==== | ||
+ | |||
+ | Listen code example with a default option: | ||
<code> | <code> | ||
listen ("What percentage change do you want to allow? {0..}[75] ",$percentChangeImm) | listen ("What percentage change do you want to allow? {0..}[75] ",$percentChangeImm) | ||
if $percentChangeImm == "" | if $percentChangeImm == "" | ||
- | $percentChangeImm = "75.0" | + | $percentChangeImm = "75.0" |
- | percentChangeImm[] = create (; data=75.0) | + | percentChangeImm[] = create (; data=75.0) |
else | else | ||
- | percentChangeImm[] = create (; data=$percentChangeImm) | + | percentChangeImm[] = create (; data=$percentChangeImm) |
endif | endif | ||
</code> | </code> | ||
Line 54: | Line 55: | ||
The syntax of the menu command is: | The syntax of the menu command is: | ||
- | menu (prompt, numItems, item1, ..., itemN, $choices[]) | + | menu (prompt, numItems, item1, ..., itemN, $choices[]; {defaultChoice={1..N}, {oneChoice={true,false}}}) |
where | where | ||
Line 65: | Line 66: | ||
//$choices[]// is an array of boolean TOOL variables. After the user has entered their menu choices, this array will contain true if the menu item has been selected and false if it has not. This array must be at least as big as the number of items in the menu. | //$choices[]// is an array of boolean TOOL variables. After the user has entered their menu choices, this array will contain true if the menu item has been selected and false if it has not. This array must be at least as big as the number of items in the menu. | ||
+ | |||
+ | //defaultChoice// is an integer that specifies which option is the default selection if the user does not make a selection. | ||
+ | |||
+ | //oneChoice// is an optional boolean flag that forces the user to choose only one option. | ||
+ | |||
+ | //**note:**// If both //defaultChoice// and //oneChoice// are used, defaultChoice must precede oneChoice. | ||
=== Example === | === Example === |