askNumber

Built-ins

Canonical ID: input.readNumber. Nederlands: vraagGetal.

Asks for a number between the minimum and maximum and returns a Number.

Inclusive bounds include the endpoints: a minimum of 1 and maximum of 5 allow 1 and 5 too. Finite excludes infinity and invalid numeric values. Trimming whitespace removes spaces and similar characters at the start and end. Normalizing changes an accepted spelling to one agreed form, such as the reply "2,5" becoming 2.5.

Exponent notation in a number reply, such as 1e2, means one times ten to the power two: 100. A sign is + or -. These are rules for answering a question; they do not make 1e2 a valid Pliro source-number literal. A particular input box may restrict what you can type.

The input flow handles invalid replies before returning a value.

Signature

askNumber(prompt, minimum, maximum)

Arguments

Parameter Type Requirement
prompt Text Question displayed by the host.
minimum Number Finite inclusive lower bound, no greater than maximum.
maximum Number Finite inclusive upper bound.

Return value

Number.

Example

# language: en
let level = askNumber("Level: 1-5", 1, 5)
say level * 10

Entering 3 prints 30.

Notes and common mistakes

Use the function name for your source language. Its canonical ID is a shared documentation label; you do not type that ID as a call. Giving your own variable or function the same name can hide the built-in. Supply the documented arguments and value types. Pliro reports mismatches when checking can detect them, or when the call runs.

The selected host mediates input. Program replies are bounded to 64 KiB of valid UTF-8; unavailable input produces E4010. Keyboard names and option strings are data and are not translated with source syntax. Completed prompts are cooperative checkpoints.

ask · askYesNo · choose · keyDown · Programming guides · Host support · Calls and arguments