Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

READ/READF


Syntax | Arguments | Keywords | Examples | Version History | See Also

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.

Syntax

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

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

Keywords: [, AM_PM=[string, string]] [, DAYS_OF_WEEK=string_array{7 names}] [, FORMAT=value] [, MONTHS=string_array{12 names}] [, PROMPT=string]

Arguments

Prompt

Note
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. 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.

Vari

The named variables to receive the input.

Note
Vari may not be an element of an array variable (arrayvar[n]) or a field within a structure variable (structvar.tag). See Parameter Passing Mechanism for details.

If the variable specified for the Vari argument has not been previously defined, the input data is assumed to be of type float, and the variable will be created as a float.

Keywords

AM_PM

Supplies a string array of two names to be used for the names of the AM and PM string when processing explicitly formatted dates (CAPA, CApA, and CapA format codes) with the FORMAT keyword.

DAYS_OF_WEEK

Supplies a string array of 7 names to be used for the names of the days of the week when processing explicitly formatted dates (CDWA, CDwA, and CdwA format codes) with the FORMAT keyword.

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.

MONTHS

Supplies a string array of 12 names to be used for the names of the months when processing explicitly formatted dates (CMOA, CMoA, and CmoA format codes) with the FORMAT keyword.

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.

Obsolete Keywords

The following keywords are obsolete:

For information on obsolete keywords, See Obsolete Features.

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.

Examples

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

; Define B as a string before reading: 
B = '' 
 
; Read input from the terminal: 
READ, B, PROMPT='Enter Name: ' 

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

READF, 7, C 

Version History

Introduced: Original

See Also

READS, READU, WRITEU


Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]