basic.in Statement/BASIC Program

basic.in

Command basic.in Statement/BASIC Program
Applicable release versions: AP, R83 2.2, R83 3.0, R83 3.1
Category BASIC Program (486)
Description accepts a single character of input from the keyboard, without displaying a prompt character or requiring a <return> following the input.

A character is retrieved from the type-ahead buffer without being processed and is converted to its equivalent decimal value before being assigned to the variable.

For example, when the <backspace> key is pressed, the "in" statement retrieves an "8". When the <linefeed> key is pressed, the value is "10".

The "time.expression" specifies the maximum time that the system waits for input before returning to the Pick/BASIC program, until either of the following occur:

When a character is entered, the "then" clause is taken.

When a character is not entered in the allocated time, the "else" clause is taken.

The "time.expression" is expressed in tenths of a second, as a positive integer from 1 to 32767. If "time.expression" is zero and there is at least one character in the input buffer, the first character is returned and the "then" clause is taken. If "time.expression" is zero and there is no character available in the input buffer, the "in" statement returns immediately and the "else" clause is taken. If "time.expression" is negative, then no timeout is in effect. The system waits indefinitely for the character.

The "then" clause is executed if valid input occurs during the specified timeout. The "else" clause is taken in no input occurs during the allocated time.

See the "then/else construct" for an explanation on the use of "then" and "else" clauses in statements that allow or require them.

As of AP release 5.2.3, a "length.expresison" of 0 (zero) is allowed in the "input" statement. This syntax is more consistant with other implementations of Pick. See example 3.
Syntax in variable {for time.expression {then | else statement.block}
Options
Example
loop
 in key
until key = 13 do repeat

This program loops until a carriage return (char(13)) is pressed.

maxtime = 300 ;* 30 seconds
in key for maxtime else
 crt 'timeout occured'
end

In this example, the system waits for "key" for 30 seconds. If no 
keystroke is provided within 30 seconds, 'timeout occured' is 
displayed and the program stops.

input x,0
x = seq(x)

These two lines perform exactly the same as:

in x
Purpose
Related basic.statements
basic.then/else.construct
basic.input@
basic.get
basic.send
statement.block
ue.d0ba