Using ASSOC with structures
How do I use ASSOC with structures?
A structure may be used in an ASSOC statement to read data from a file. A direct reference to a field of the sub-scripted variable used in the ASSOC statement is not allowed, however. To access the data in the structure, first assign an element of the associated variable to a temporary variable, and then specify a structure field of the temporary variable. The following examples illustrate the necessary technique.
INCORRECT
---------
OPENR, 1, 'test.dat'
a= {data, flts:FLTARR(10), ints:INTARR(20)}
b= ASSOC, 1, a
PRINT, b(0).flts ;This structure reference of a subscripted
;variable is not successful
CORRECT
-------
OPENR, 1, 'test.dat'
a= {data, flts:FLTARR(10), ints:INTARR(20)}
b= ASSOC(1, a)
c= b(0) ;Use a temporary variable
PRINT, c.flts ;Now complete the structure reference