Re: writing a structure with pointers [message #12279] |
Wed, 15 July 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Lisa Bryan (lbryan@arete-az.com) writes:
> Could someone tell me the easiest way to do the following.
>
> state = {.....big long huge structure with many substructures and lots
>
> of pointers all over the place....}
> writeu,unit,state
>
> I'm trying to write my state structure into an unformatted file and
> get the error:
>
> WRITEU: Expression containing pointers not allowed in this context:
> STATE.
Oh, oh. Looks like someone will have to write a recursive
procedure to example the fields of structures and dereference
the pointer fields. It is a shame there isn't a DEREFERENCE
keyword that could be used with the WRITEU command.
The alternative, of course, is to SAVE the structure. SAVE
will store the pointers along with the data they point to, so
that all can be RESTORED later. This is not always my preferred
solution, since it is not guaranteed to work with IDL upgrades
and variables that are not named carefully can be a problem.
I can imagine that pointer variables might be even more
difficult to handle than normal variables.
Absent RSI adding some capability to WRITEU, how about you
let us know when you have this program written, Lisa. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|