AmigaOS 4.0 - About OS4 - Commands
|
||||||||
|
||||||||
|
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: IF WARN ECHO Yes ELSE ECHO No ENDIF 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 Assume a script called 'ASKTEST2' contained the following commands: IF $reply EQ 1 ECHO Yes ELSE ECHO No ENDIF 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 Assume a script called 'ASKTEST3' contained the following commands: IF $reply EQ 1 ECHO Yes ELSE ECHO No ENDIF 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
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. |