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

Home » Public Forums » archive » Re: structure into strcuture
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: structure into strcuture [message #56233] Fri, 12 October 2007 11:32
natha is currently offline  natha
Messages: 482
Registered: October 2007
Senior Member
Thanks :)
Re: structure into strcuture [message #56285 is a reply to message #56233] Fri, 12 October 2007 11:12 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
natha wrote:
> Hi Gurus,
>
> I want to declare an object structe with 4 structures inside. Is it
> possible ?
>
> My class has 4 structures with 10 to 15 variables.
> I declare the object like this example:
>
> PRO objectA__define
> struct = { objectA, $
> struct_a={ a1:0L, $
> a2:0L $
> }, $
> struct_b={ b1:0L, $
> b2:0L $
> } $
> }
> END
>
> But IDL can't compile...
> Maybe I need to declare everyone as a pointer and redifine every
> structure in the Init function but I don't want to do this.

With

PRO objectA__define
void = { objectA, $
struct_a: { a1:0L, a2:0L }, $
struct_b: { b1:0L, b2:0L } $
}
END

I get:

IDL> .run objecta__define
% Compiled module: OBJECTA__DEFINE.
IDL> x={objecta}
% Named structures can't contain anonymous structure members
% Execution halted at: OBJECTA__DEFINE 3 /export/lnx374/wd20pd/scratch/objecta__define.pro
% $MAIN$

So what about something like:


PRO objectA__define
void = { objectA, $
struct_a: {struct_a, a1:0L, a2:0L }, $
struct_b: {struct_b, b1:0L, b2:0L } $
}
END

IDL> x={objecta}
% Compiled module: OBJECTA__DEFINE.
IDL> help, x, /struct
** Structure OBJECTA, 2 tags, length=16, data length=16:
STRUCT_A STRUCT -> STRUCT_A Array[1]
STRUCT_B STRUCT -> STRUCT_B Array[1]



.....OR.....



PRO mystruct__define
void = { mystruct, $
x1:0L, $
x2:0L $
}
END

PRO objectA__define
void = { objectA, $
struct_a: {mystruct}, $
struct_b: {mystruct} $
}
END

IDL> .run objecta__define
% Compiled module: MYSTRUCT__DEFINE.
% Compiled module: OBJECTA__DEFINE.
IDL> x={objecta}
IDL> help, x, /struct
** Structure OBJECTA, 2 tags, length=16, data length=16:
STRUCT_A STRUCT -> MYSTRUCT Array[1]
STRUCT_B STRUCT -> MYSTRUCT Array[1]

Of course, you would define the various XXX__define procedures as needed if each is a
different structure.


cheers,

paulv
Re: structure into strcuture [message #56286 is a reply to message #56285] Fri, 12 October 2007 10:57 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
I think the problem here is just how you did it. It works for me, try
this code

IDL> a={ a1:0l, a2:1l }
IDL> b={ b1:0l, b2:1l }
IDL> c = {a:a, b:b}
IDL> help, c
C STRUCT = -> <Anonymous> Array[1]
IDL> help, c, /str
** Structure <22cbb14>, 2 tags, length=16, data length=16, refs=1:
A STRUCT -> <Anonymous> Array[1]
B STRUCT -> <Anonymous> Array[1]
IDL> print, c.a.a1
0





Cheers,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: map_set and limit question
Next Topic: Re: Bug in SWITCH - ELSE: statement?

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

Current Time: Wed Oct 08 14:00:57 PDT 2025

Total time taken to generate the page: 0.00611 seconds