Input

From MiniScript Wiki
Revision as of 04:04, 20 January 2021 by JoeStrout (talk | contribs) (Created page with "<c>input</c> is a quasi-standard function in the MiniScript language that gets a string of input from the user. By "quasi-standard" we mean that it is not part of the MiniScr...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

input is a quasi-standard function in the MiniScript language that gets a string of input from the user. By "quasi-standard" we mean that it is not part of the MiniScript core, but several implementations support it, and embedders are encouraged to add support for it whenever possible.

Syntax:

 input(prompt)

The prompt is optional, and if supplied, is printed to output (as if with print). The script then blocks while the user types a response, terminated by Return or Enter. The text entered (without the terminating line break) is returned as the value of the function.

Note that input always returns a string. To interpret the input as a number, use val.

Example

The following example asks the user's age, and then reports their age in dog years.

age = input("How old are you? ").val
print "That's " + age*7 + " in dog years."