Home Page The Club Computers News Links Glossary EYAWTK
Before Amiga Background ICS OCS ECS AGA ??? PPC
U-Boot SLB Linux Amiga OS Dual Boot Motherboards Peripherals Other
Initialisation Installation OS4 Updates About OS4 File Systems Networking Printing Other
Introduction File System Workbench Preferences Commands Error Msgs Miscellaneous

AmigaOS 4.0 - About OS4 - Commands

ASK Internal
Purpose: To obtain user input when executing a script file.
Format: ASK <prompt> [TO <to>] [NUMERIC] [STRING]
Template: PROMPT/A, TO/K, NUMERIC/S, STRING/S
Path: Internal
ASK is used in scripts to write the string specified by <prompt> to the current window then wait for keyboard input.

If the <prompt> contains spaces, it must be enclosed in quotation marks (").

By default, valid keyboard response are Y(yes), N (no), and Return/Enter (no). If you press Y followed by Return or Enter, ASK sets the condition flag to 5 (WARN). If you press N followed by Return or Enter, or simply press Return or Enter, the condition flag is set to 0. If any other value is pressed before Return or Enter, the prompt is re-displayed until an acceptable value is entered. To check which key was pressed you can use an IF statement.

If the TO <to> argument is specified, the processing is quite different to the above. Instead of setting the condition flag to 5 or 0 is, it is set to either 1 or 0 respectively, and used to set the value of the local variable specified by <to> unless STRING or NUMERIC is specified.

If the STRING option is specified, the processing is quite different again. The condition flag is not set and the value entered is returned instead irrespective of the value, except when ; (semi-colon) is included in the string which is interpreted as end of value. If no value is entered the prompt is re-displayed. If the TO <to> argument is specified the value entered is used to set the value of the local variable specified by <to>.

If the NUMERIC option is specified, the processing is similar to the STRING option except only numeric values are acceptable. If no value is entered, or the value is non-numeric, the prompt is re-displayed. Again if a ; (semi-colon) is included in the string it is interpreted as end of value. If the TO <to> argument is specified the value entered is used to set the value of the local variable specified by <to>.

Example 1:

Assume a script called 'ASKTEST' contained the following commands:

ASK "Do you want to continue?"
IF WARN
  ECHO Yes
ELSE
  ECHO No
ENDIF
If we now execute the 'ASKTEST1' script and test various replies we see. 3.OS4:> ASKTEST1
Do you want to continue? y <RETURN>
Yes
3.OS4:> ASKTEST1
Do you want to continue? n <RETURN>
No
3.OS4:> ASKTEST1
Do you want to continue? <RETURN>
No
3.OS4:> ASKTEST1
Do you want to continue? a <RETURN>
Do you want to continue? 1 <RETURN>
Do you want to continue? y <RETURN>
Yes
Example 2:

Assume a script called 'ASKTEST2' contained the following commands:

ASK "Do you want to continue?" TO reply
IF $reply EQ 1
  ECHO Yes
ELSE
  ECHO No
ENDIF
If we now execute the 'ASKTEST2' script and test various replies we see. 3.OS4:> ASKTEST2
Do you want to continue? y <RETURN>
Yes
3.OS4:> ASKTEST2
Do you want to continue? n <RETURN>
No
3.OS4:> ASKTEST2
Do you want to continue? <RETURN>
No
3.OS4:> ASKTEST2
Do you want to continue? a <RETURN>
Do you want to continue? 1 <RETURN>
Do you want to continue? y <RETURN>
Yes
Example 3:

Assume a script called 'ASKTEST3' contained the following commands:

ASK "Do you want to continue?" TO reply
IF $reply EQ 1
  ECHO Yes
ELSE
  ECHO No
ENDIF
If we now execute the 'ASKTEST3' script and test various replies we see. 3.OS4:> ASKTEST3
Do you want to continue? y <RETURN>
Yes
3.OS4:> ASKTEST3
Do you want to continue? n <RETURN>
No
3.OS4:> ASKTEST3
Do you want to continue? <RETURN>
No
3.OS4:> ASKTEST3
Do you want to continue? a <RETURN>
Do you want to continue? 1 <RETURN>
Do you want to continue? y <RETURN>
Yes

See also: IF, ELSE, ENDIF, REQUESTCHOICE, REQUESTSTRING


Return to Commands Selection

Disclaimer: Amiga Auckland have prepared the above information for the use of its members based on our experiences and as such is subject to revision at any time. Amiga Auckland cannot guarantee any of the information and cannot be held accountable for any issues that may result from using it.


Copyright 2006 Amiga Auckland Inc. All rights reserved.
Revised: February 9, 2006.