READ/READF

The READ procedures perform formatted input into variables.

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

Calling Sequence

READ, [Prompt,] Var 1 , ..., Var n

or

READF, [Prompt,] Unit, Var 1 , ..., Var n

Arguments

Prompt

Note that the PROMPT keyword should be used instead of the Prompt argument for compatibility with window-based versions of IDL.

A string or explicit expression (i.e, not a named variable) to be used as a prompt. This argument should not be included if the FORMAT keyword is specified. Also, if this argument begins with the characters "$(", it is taken to be a format specification as described below under "Format Compatibility".

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.

Var i

The named variables to receive the input.

Keywords

FORMAT

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 .

PROMPT

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.

VMS Keywords

Note also that the obsolete VMS-only routine READ_KEY has been replaced by the keywords below.

KEY_ID

The index key to be used (primary = 0, first alternate key = 1, etc...) when accessing data from a file with indexed organization. If this keyword is omitted, the primary key is used.

KEY_MATCH

The relation to be used when matching the supplied key with key field values (EQ = 0, GE = 1, GT = 2) when accessing data from a file with indexed organization. If this keyword is omitted, the equality relation (0) is used.

KEY_VALUE

The value of a key to be found when accessing data from a file with indexed organization. This value must match the key definition that is determined when the file was created in terms of type and size--no conversions are performed. If this keyword is omitted, the next sequential record is used.

Format Compatibility

If the FORMAT keyword is not present and READ is called with more than one argument, and the first argument is a scalar string starting with the characters "$(", this initial argument is taken to be the format specification, just as if it had been specified via the FORMAT keyword. This feature is maintained for compatibility with version 1 of VMS IDL.

Example

To read a string value into the variable B from the keyboard, enter:

B = '' ; Define B as a string before reading.

READ, B, PROMPT='Enter Name: ' ; Read input from the terminal.

To read formatted data from the previously-opened file associated with logical unit number 7 into variable C, use the command:

READF, 7, C

See Also

READS , READU , WRITEU