STRING(structure) curiosity [message #66067] |
Fri, 10 April 2009 13:30 |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
I am using some old code that applies the STRING function to a
structure. This surprised me because I didn't think it was possible.
IDL> a = { v1:bindgen(5), v2:!dpi, v3:['idl','structure'] }
IDL> print,string(a)
% STRING: Struct expression not allowed in this context: A.
The reason it works in the old code is that it used a format statement
IDL> print,string(a,f='( 5i3, f10.6, 2a10) ')
0 1 2 3 4 3.141593 idl structure
So it appears you can apply the STRING function to a structure but you
*must* then supply a format statement. I actually like this
behavior, but I can't find it documented anywhere. Applying STRING
to a structure allows one to efficiently write the structure to an
ASCII file, but I would think that one would always want to specify
the format in such a case. --Wayne
|
|
|