Read Procedures

The READ procedures perform formatted input into variables.

READ performs input from the standard input stream (IDL file unit 0, usually the keyboard), while READF requires a file unit number to be explicitly specified.

Calling Sequence

READ, [Prompt,] Var1, ..., Varn
READF, [Prompt,] Unit, Var1, ..., Varn


A string to be used as a prompt. This argument should not be included if the FORMAT keyword is specified.
Using the Prompt argument does not work well with IDL for Windows and IDL for Macintosh. The desired prompt string is written to the log window instead of the command input window. To create custom prompts compatible with these versions of IDL, use the PROMPT keyword, described below.

Unit For READF, Unit specifies the file unit from which the input is taken. This is the Unit that is created by using one of the OPEN procedures.

Vari The named variables to receive the input.


If FORMAT is not specified, IDL uses its default rules for formatting the input. FORMAT allows the format of the input to be specified in precise detail, using a FORTRAN-style specification. See "Using Explicitly Formatted Input/Output" on page 161 of Building IDL Applications.

Set this keyword to a scalar string to be used as a customized prompt for the READ command. If the PROMPT keyword or Prompt argument is not supplied, IDL uses a colon followed by a space (": ") as the input prompt.

To request the user to provide a value for a variable:
READ, x, PROMPT='Type a value for the length of the room in feet'

Open unit 2 to a file and read five values into an array w using the default read format settings:
OPENR, 2, filename