ASSOC Function
Associates
Usage
Input Parameters
unit—The file unit to associate with array_definition.
array_definition—An expression that defines the data type and dimensions of the associated data.
offset—The offset in the file to the start of the data in the file. For stream files and RMS block mode files, this offset is given in bytes. For RMS record-oriented files, this offset is specified in records.
Returned Value
result—A variable that associates the array definition with the file.
Keywords
None.
Discussion
ASSOC provides a basic method of random access input/output. The associated variable (the one storing the association) is created by assigning the result of ASSOC to a variable. This variable provides a means for mapping a file into vectors or arrays of a specified type and size.
Example
Assume you have a binary file, image_file.img
, with five 512-by-512 byte images and a 1024-byte header:
; Open the file. OPENR, 1, 'image_file.img' aimage = ASSOC(1, BYTARR(512, 512), 1024) ; Read the first image. image1 = aimage(0) ; Read the fifth image. image5 = aimage(4) ; Display the third image. TVSCL, aimage(2) ; Do an FFT function on the second image. fft_image = FFT(aimage (1), -1) arow = ASSOC(1, BYTARR(512), 1024) ; Read the 100th row. row100 = arow(99) ; Plot the first row in the second image. PLOT, arow(512)