GET_KBRD

The GET_KBRD function returns the next character available from the standard input (IDL file unit 0) as a one-character string.

Calling Sequence

Result = GET_KBRD( Wait )

Arguments

Wait

If Wait is zero, GET_KBRD returns the null string if there are no characters in the terminal type-ahead buffer. If it is nonzero, the function waits for a character to be typed before returning.

Examples

To wait for keyboard input and store one character in the variable R, enter:

R = GET_KBRD(1)

Press any key to return to the IDL prompt. To see the character that was typed, enter:

PRINT, R

The following code fragment reads one character at a time and echoes that character's numeric code. It quits when a "q" is entered:

REPEAT BEGIN

  A = GET_KBRD(1)

  PRINT, BYTE(A)

ENDREP UNTIL A EQ 'q'

For example, to return the paragraph marker (¶), ANSI number 0182, enter:

C = GET_KBRD(1)

While GET_KBRD is waiting, press and hold the Alt key and type 0182 on the numeric keypad. When the IDL prompt returns, enter:

PRINT, C

IDL should print the paragraph marker,"¶".

GET_KBRD cannot be used to return control characters, the Return key, or other editing keys (e.g., Delete, Backspace, etc.). These characters are used for keyboard shortcuts and command line editing only.

See Also

READ/READF