Difference between revisions of "Shell Commands/RequestChoice"

From MorphOS Library

< Shell Commands

(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...")
 
m
 
(2 intermediate revisions by 2 users not shown)
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 20: Line 22:
 
  <nowiki>
 
  <nowiki>
 
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 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:
 +
<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
 +
If $rcnum EQ 0
 +
; User cancelled shutdown procedure
 +
Quit
 +
Endif
 +
</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