Skip to main content


Reads a single character of user input.


IN variable [FOR timeout [THEN statements] [ELSE statements]]


variable A variable used to hold the user input character.
FOR timeout Optional — An expression that resolves to an integer specifying the number of tenths of a second to wait for input before timing out. A timeout value of 0 is permitted. The FOR clause requires either a THEN clause or an ELSE clause, or both.


The IN statement pauses program execution for user input, then reads a single character of user input into variable. The character is stored in variable as an ASCII code value. It is therefore necessary to use the CHAR function to display the character.

You specify the timeout value in tenths of a second; however, Caché only handles timeout in whole seconds. Caché rounds this timeout value to an integer number of whole seconds. Any timeout value less than 10 is rounded up to one second.

If no FOR clause is specified, the IN statement pauses execution indefinitely until receiving user input. The FOR clause, which is used with the THEN and ELSE clauses, provides for timeout of this pause for user input.

If you have specified a FOR clause, you can optionally specify a THEN clause, an ELSE clause, or both a THEN and an ELSE clause. If the user input occurs within the FOR timeout, the THEN clause is executed. If the user input does not occur within the FOR timeout, the ELSE clause is executed. The statements argument can be the NULL keyword, a single statement, or a block of statements terminated by the END keyword. A block of statements has specific line break requirements: each statement must be on its own line and cannot follow a THEN, ELSE, or END keyword on that line.

By default, the input character is not echoed, regardless of the setting of ECHO. However, echoing is emulation-dependent. For example, in D3 emulation the input character is always echoed, regardless of the setting of ECHO. The user value is echoed to the terminal; it is never echoed to the printer.

If you specify Ctrl-C as the user input to IN, the process enters the ObjectScript (COS) debugger. It displays the instruction “Type G to continue or Q to exit.” You can disable this use of Ctrl-C by specifying the BREAK OFF statement before issuing the IN statement.

You can also use the KEYIN function to receive a single character of user input, or the INPUT statement to receive one or more characters of user input. You can use the <<...>> inline prompt to prompt for a user input value to insert in a MVBasic statement or a MultiValue command line command. The <<...>> inline prompt is described in the Caché MultiValue Commands Reference.

See Also

FeedbackOpens in a new tab