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

Home » Public Forums » archive » Re: taming the shrew, a.k.a. structure
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: taming the shrew, a.k.a. structure [message #26001 is a reply to message #25990] Wed, 01 August 2001 07:35 Go to previous messageGo to previous message
marc schellens[1] is currently offline  marc schellens[1]
Messages: 183
Registered: January 2000
Senior Member
Using IDL 5.4 I get the following:

IDL> month_struct = {month_struct, name: ptr_new( ), day: ptr_new( ),
temp_c:ptr_new( )}
IDL> station = {station, number:0L, month:{month_struct}}
IDL> po_basin = replicate (station,10)
IDL> help,po_basin
PO_BASIN STRUCT = -> STATION Array[10]
IDL> po_basin.month.name = ptr_new( strarr(2190) )
IDL> help,po_basin.month.name
<Expression> POINTER = Array[10]
IDL> help,po_basin[0].month.name
<Expression> POINTER = <PtrHeapVar1>
IDL> help,po_basin[1].month.name
<Expression> POINTER = <PtrHeapVar1>

note that you set all 10 (or howmany ever) pointer to the SAME heap
variable. I assume somehow later therefore you will get an error.

This is a situation were you definitely (objections?) need a for loop:

for i=0,9 do po_basin[i].month.name= ptr_new( strarr(2190))

Anyway, your snippet works without error.
But you are right,
an object would do the task indeed more elegant/ less error-prone.

hope this helps,
marc


HILBERMAN wrote:
>
> To put it simply, you rock. I have now successfully created a mess: an
> array of a structure
> that contains another embedded structure. Unfortunately, I'm still not
> 'pointed' in the right
> direction. When I try to apply the pointer tip to 'the mess' I get the
> error:
> % Conflicting data structures: <POINTER (<NullPointer>)>,MONTH_STRUCT.
>
> Here's how I have things set up right now.
> month_struct = {month_struct, name: ptr_new( ), day: ptr_new( ), temp_c:
> ptr_new( )}
> station = {station, number:0L, month:{month_struct}}
> po_basin = replicate (station, howmany)
>
> po_basin.month.name = ptr_new( strarr(2190) )
> ...
>
> Any ideas? Since station references a structure with pointers, do I have to
> make a pointer to
> station as well--or something similar? I can't say I know a lick about
> objects, but this is
> kinda seeming like a problem to be solved by an object? Oyvey.
>
> Cheers,
> Davida
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL and Beowolf ?
Next Topic: Re: polar contour plots

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

Current Time: Wed Oct 08 18:43:28 PDT 2025

Total time taken to generate the page: 0.00423 seconds