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

Examples


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

; Open the file for reading as file unit 1:
OPENR, 1, FILEPATH('people.dat', SUBDIR = ['examples','data'])
; The image is a 192 by 192 byte array, so make B that size:
B = BYTARR(192, 192, /NOZERO)
; Read the data into B:
READU, 1, B
; Close the file:
CLOSE, 1
; Display the image:
TV, B

Syntax


READU, Unit, Var1, ..., Varn [, TRANSFER_COUNT=variable]

Arguments


Unit

The IDL file unit from which input is taken.

Vari

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

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


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 RAWIO 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 RAWIO keyword. Instead, the programmer must keep track of the transfer count.

Version History


Original

Introduced

Pre-6.2

Deprecated KEY_ID, KEY_MATCH, and KEY_VALUE keywords

 

See Also


READ/READFREADSWRITEU