Previous Topic: Writing Data to the Console (stdout)Next Topic: Accessing the Operating System


Reading Data from the Keyboard (stdin)

If a script requires input while it is running, use one of the following commands:

wait

Waits for a key press and optionally stores the typed character in a variable.

accept

Reads a string from the keyboard (stdin) until enter is pressed:

Examples

Wait until an arbitrary key has been pressed:

wait "Press any key…"

Wait until one key has been pressed and store the resulting character in the variable ch.

wait ""Press any key" to ch

Read a string until an enter is encountered and store it to the variable str.

accept to str

Display the prompt message "Enter amount: ", read the input string until an enter is encountered, and store it to the variable str.

accept "Enter amount: " to str