Re: undefining structures ? [message #1595 is a reply to message #1564] |
Mon, 06 December 1993 13:35  |
offenbrg
Messages: 31 Registered: August 1993
|
Member |
|
|
lucio@ifctr.mi.cnr.it (Lucio Chiappetti) writes:
Newsgroups: comp.lang.idl-pvwave
Subject: Re: undefining structures ?
Distribution: world
References: <Pine.3.05.9312061924.D19888-c100000@poseidon.ifctr.mi.cnr.it>
lucio@ifctr.mi.cnr.it (Lucio Chiappetti) writes:
> This structure will have a number of members s.keyname corresponding to
> keywords, and a member s.data.
> The member s.data is created as: data:replicate(template,nrows)
> template= {record,TIME:0L, THETA:0L, PHI:0L, ENERGY:0 , undef:0B}
> where the names and types of the tags are constructed by my procedure
> according to information in the file itself. So later I can access the
> individual columns as s.data.time, etc.
Bad news. As far as I know (and if anyone knows better, please let me know),
IDL won't let you do what you're trying to do.
(a) You can't make "template" an anonymous structure because you're using
it as part of another structure.
(b) Once defined within an IDL session, a structure name (like "RECORD")
can't be renamed.
The quick & dirty way out of it, as I see it, is to have each different
version of TEMPLATE have a different structure name (e.g. REC1, REC2, etc).
Another way would be to skip TEMPLATE entirely, and just create one
structure, with s.keyname, s.time, s.theta, etc.
A third way would be to: instead of making DATA a structure, you
make it an array, like an array of strings, and put the data in the array in
a consistent format.
For example, you could create the S structure with 3 words: s.keynames,
s.formats and s.data. Then you'd encode TIME as, say, an 8-digit integer
starting at the fifth character of each line. You'd record the format in
the s.formats array, such as '(4x,i8)'. Then to read it out, you'd say
something like
reads,s.data,time,f=s(where(s.keynames eq 'TIME')).formats
Yeah, its convoluted. But, it would work. And you could easily whip up
a function to do the read statement for you, like
time = readmystruc(s,'TIME')
> PS
> I'm using IDL 2.2.1 (and I'm not likely to update it for the time being)
Unless they've changed this for the just-released IDL 3.5, the version of IDL
doesn't matter.
Hope all of this helps.
Joel
--
Joel D Offenberg | "Aren't you in the position of a life-long
Hughes STX/ UIT Science Team | vegetarian giving us your recipe for steak
offenbrg@fondue.gsfc.nasa.gov | and kidney pie?" - Rumpole of the Bailey
I get paid to stare into space. |
|
|
|