Difference between revisions of "Shell Commands/RequestChoice"
From MorphOS Library
(Created page with "'''RequestChoice''' - Asks for input via a requester TITLE/A, BODY/A, GADGETS/A/M, PUBSCREEN/K <nowiki> TITLE - Title string of the requester...") |
|||
Line 1: | Line 1: | ||
'''RequestChoice''' - Asks for input via a requester | '''RequestChoice''' - Asks for input via a requester | ||
− | TITLE/A, BODY/A, GADGETS/A/M, PUBSCREEN/K | + | TITLE/A, BODY/A, GADGETS/A/M, PUBSCREEN/K,TYPE/K,TIMEOUT=TIMEOUTSECS/K/N |
<nowiki> | <nowiki> | ||
TITLE - Title string of the requester | TITLE - Title string of the requester | ||
Line 8: | Line 8: | ||
GADGETS - Gadgets of the requester (see below) | GADGETS - Gadgets of the requester (see below) | ||
The gadget labels are separated with spaces | The gadget labels are separated with spaces | ||
− | PUBSCREEN - Optional: name of the publicscreen to use</nowiki> | + | PUBSCREEN - Optional: name of the publicscreen to use |
+ | TYPE - Type of the requester (not implemented yet) | ||
+ | TIMEOUT - Time in seconds to cancel the requester</nowiki> | ||
The number of the selected gadget is printed as a result to the console. | The number of the selected gadget is printed as a result to the console. | ||
For evaluation in a script file, you can redirect this output | For evaluation in a script file, you can redirect this output | ||
Line 21: | Line 23: | ||
MorphOS:> RequestChoice >ENV:rcnum "New Title" "This is my requester*NSelect a gadget" "OK" "Maybe" "Cancel"</nowiki> | MorphOS:> RequestChoice >ENV:rcnum "New Title" "This is my requester*NSelect a gadget" "OK" "Maybe" "Cancel"</nowiki> | ||
ENV:rcnum contains 0, 1, or 2 after a gadget is selected. The script can use this value to control its later execution. | ENV:rcnum contains 0, 1, or 2 after a gadget is selected. The script can use this value to control its later execution. | ||
+ | |||
+ | |||
+ | Example script: | ||
+ | <nowiki> | ||
+ | RequestChoice >ENV:rcnum "Shutdown Requester" "Press enter to shutdown or wait 10s to cancel." "Shutdown" "Reboot" "Cancel" TYPE=1 TIMEOUT=10 | ||
+ | If $rcnum EQ 1 | ||
+ | ShutDown | ||
+ | Quit | ||
+ | EndIf | ||
+ | If $rcnum EQ 2 | ||
+ | Reboot | ||
+ | Quit | ||
+ | EndIf</nowiki> |
Revision as of 13:39, 6 March 2015
RequestChoice - Asks for input via a requester
TITLE/A, BODY/A, GADGETS/A/M, PUBSCREEN/K,TYPE/K,TIMEOUT=TIMEOUTSECS/K/N
TITLE - Title string of the requester BODY - Body string of the requester Linefeeds can be embedded using *N GADGETS - Gadgets of the requester (see below) The gadget labels are separated with spaces PUBSCREEN - Optional: name of the publicscreen to use TYPE - Type of the requester (not implemented yet) TIMEOUT - Time in seconds to cancel the requester
The number of the selected gadget is printed as a result to the console. For evaluation in a script file, you can redirect this output into an environment variable. If the requester cannot be opened, the command generates a return code of 20.
The PUBSCREEN argument allows the requester to open its window on a public screen.
Example:
MorphOS:> RequestChoice >ENV:rcnum "New Title" "This is my requester*NSelect a gadget" "OK" "Maybe" "Cancel"
ENV:rcnum contains 0, 1, or 2 after a gadget is selected. The script can use this value to control its later execution.
Example script:
RequestChoice >ENV:rcnum "Shutdown Requester" "Press enter to shutdown or wait 10s to cancel." "Shutdown" "Reboot" "Cancel" TYPE=1 TIMEOUT=10 If $rcnum EQ 1 ShutDown Quit EndIf If $rcnum EQ 2 Reboot Quit EndIf