Difference between revisions of "Shell Commands/RequestChoice"
From MorphOS Library
(Clarify the values returned by requestchoice) |
m |
||
Line 40: | Line 40: | ||
; User cancelled shutdown procedure | ; User cancelled shutdown procedure | ||
Quit | Quit | ||
+ | Endif | ||
</nowiki> | </nowiki> |
Latest revision as of 21:11, 8 July 2016
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 1, 2 or 0 respectively after a gadget is selected. The script can use this value to control its later execution.
Note that whatever the name or number of gadgets specified the first gadget always returns a 1, the second gadget returns a 2, etc, and the final gadget returns a 0.
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 If $rcnum EQ 0 ; User cancelled shutdown procedure Quit Endif