comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: STRUCT_ASSIGN
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: STRUCT_ASSIGN [message #12620] Sun, 23 August 1998 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Robert S. Mallozzi wrote:
>
> Hi all,
>
> I have a structure defined as follows:
>
> a = { f1: 0, f2: { x: 0, y: 0}}
>
> [...]

> So, must I resort to field-by-field copy? The problem
> is that "a" is actually an object ("self"), which has
> some member variables that are large structures.
> A field-by-field copy would be tedious, as each
> structure has on the order of 30 fields, or so.
> I wanted to write a generic "set" method that will
> initialize the object's structures with some data.
> If I must do a field-by-field copy, I would then
> have to have several "set" methods, each of which is
> specialized for each of the different stuctures
> within the object.
>

As Mark points out, the problem here is that you are actually using two
different anonymous structures. There has been a recent discussion in
this newsgroup about a similar problem: If you type help,a.f2,data,/stru
you will se something like :

** Structure <10304508>, 2 tags, length=4, refs=2:
X INT 0
Y INT 0
** Structure <10304708>, 2 tags, length=4, refs=1:
X INT 10
Y INT 20

The number in <> identifies the structure "type"...

> So, must I resort to field-by-field copy? The problem
> is that "a" is actually an object ("self"), which has
> some member variables that are large structures.
> A field-by-field copy would be tedious, as each
> structure has on the order of 30 fields, or so.
> I wanted to write a generic "set" method that will
> initialize the object's structures with some data.
> If I must do a field-by-field copy, I would then
> have to have several "set" methods, each of which is
> specialized for each of the different stuctures
> within the object.
>

What you describe here sounds like a typical application for pointers.
Nesting structures within structures within structures ... can usually
only be achieved with the help of these things. Here is an example:

a = { f1:0, f2:ptr_new() }
data = { x:10, y:20 }
a.f2 = ptr_new(data,/NO_COPY) ; careful: no_copy means
; "data" will be lost afterwards!

help,*a.f2,/stru

You can test the contents of your sub-structure with tag_names():
print,tag_names(*a.f2)

Hope, this gives a hint in the right direction,
Martin.



--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
[Message index]
 
Read Message
Read Message
Previous Topic: STRUCT_ASSIGN
Next Topic: Plotting lines between two polygons

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 14:17:48 PDT 2025

Total time taken to generate the page: 0.88188 seconds