Shell Commands/RequestChoice

From MorphOS Library

Revision as of 18:48, 8 July 2016 by Boot wb (talk | contribs) (Clarify the values returned by requestchoice)

< Shell Commands

RequestChoice - Asks for input via a requester


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.


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
If $rcnum EQ 2
If $rcnum EQ 0
; User cancelled shutdown procedure