Get.num

From AGI Wiki
Revision as of 21:00, 1 April 2019 by Andrew Korson (talk | contribs) (Created page with "The '''get.num''' command prompts the player to enter a number. == Syntax == get.num(msg mPROMPT, var vB);<br /> get.num("prompt", var...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The get.num command prompts the player to enter a number.

Syntax

get.num(msg mPROMPT, var vB);
get.num("prompt", var vB);

Remarks

Unlike the get.string command which allows customizing the input location, the get.num function uses the input line, substituting the message mPROMPT as the input prompt and using the existing cursor character. Input is limited to three characters.

When the player presses the ENTER key, the input is converted to an integer value. Leading spaces are ignored. Characters are processed until the first non-numeric character is found. For example, "1a2" will be converted to 1. If a value greater than 255 is entered, only the lower eight bits of the number are used (i.e. vB = inputval MOD 256).

If the player presses the ESC key, vB is set to 0.

When running on a system using the Hercules Graphics Card (HGC), the get.num command uses an input box similar to the normal HGC input box. The open.dialogue command will cause the get.num command to operate the same as on other systems, as described above.

Possible Errors

If input is currently disabled (by using the prevent.input command, get.num will still use the input line and get a number, but the input line will not be cleared from the screen afterward. The text will stay displayed on the input line until input is re-enabled (using the accept.input command) or the screen is redrawn by encountering a new.room command or graphics command.

Example

Code:

<syntaxhighlight lang="agi"> get.num("Enter your age: ", v99); </syntaxhighlight>

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 118 (0x76 hex)

See Also

get.string
close.dialogue
open.dialogue