READU

The READU procedure reads unformatted binary data from a file into IDL variables. READU transfers data direct ly with no processing of any kind performed on the data.

Calling Sequence

READU, Unit, Var 1 , ..., Var n

Arguments

Unit

The IDL file unit from which input is taken.

Var i

Named variables to receive the data. For non-string variables, the number of bytes required for Var are read. When READU is used with a variable of type string, IDL reads exactly the number of bytes contained in the existing string. For example, to read a 5-character string, enter:

temp = '12345'

READU, unit, temp

Unix Keywords

TRANSFER_COUNT

Set this keyword to a named variable in which to return the number of elements transferred by the input operation. Note that the number of elements is not the same as the number of bytes (except in the case where the data type being transferred is bytes). For example, transferring 256 floating-point numbers yields a transfer count of 256, not 1024 (the number of bytes transferred).

This keyword is useful with files opened with the NOSTDIO keyword to the OPEN routines. Normally, attempting to read more data than is available from a file causes the unfilled space to be zeroed and an error to be issued. This does not happen with files opened with the NOSTDIO keyword. Instead, the programmer must keep track of the transfer count.

VMS Keywords

Note that the obsolete VMS routines FORRD, and FORRD_KEY have been replaced by the READU command used with the following keywords.

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 previous key value is used.

Example

The following commands can be used to open the IDL distribution file people.dat and read an image from that file:

OPENR, 1, FILEPATH('people.dat', SUBDIR = ['examples','data'])
; Open the file for reading as file unit 1.

B = BYTARR(192, 192) ; The image we want to read is a 192 by 192 byte array, so make B that size.

READU, 1, B ; Read the data into B.

CLOSE, 1 ; Close the file.

TV, B ; Display the image.

See Also

READ/READF , READS , WRITEU