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

Home » Public Forums » archive » Re: referencing structure arrays
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: referencing structure arrays [message #68005 is a reply to message #68004] Thu, 10 September 2009 10:02 Go to previous messageGo to previous message
nivedita.raghunath is currently offline  nivedita.raghunath
Messages: 15
Registered: July 2006
Junior Member
On Sep 10, 12:36 pm, pp <pp.pente...@gmail.com> wrote:
> On Sep 10, 1:12 pm, niv <nivedita.raghun...@gmail.com> wrote:
>
>
>
>> Sorry, looks like what I typed looks gibberish in places. I hope this
>> one is more readable:
>
>> Hi All,
>
>> I have a problem referencingstructurearrays and assigning values to
>> them. So here is a snippet of my code:
>
>> junk1=update_state(junk)   ;creates astructurecalled junk1
>> statearr=replicate(junk1,3)  ;creates an array of structures
>
>> infoptr=ptr_new({statearr:statearr})  ;need this to pass variables
>> between programs
>
>> align_images,state=state1  ;some program that aligns 2 images and
>> stores the alignment results in state1
>
>> ;assign values from the state1structureto infoptr.statearr[0]
>> structure
>> (*infoptr).statearr[0].resvol_file_ptr=state1.resvol_file_pt r
>> (*infoptr).statearr[0].air_file_ptr=state1.air_file_ptr
>
>> Now, here is the problem. With the above code, it turns out that...
>
>> (*infoptr).statearr[0].resvol_file_ptr, (*infoptr).statearr
>> [1].resvol_file_ptr, (*infoptr).statearr[2].resvol_file_ptr
>> all have the same values. Similarly with air_file_ptr. Even though I
>> haven't assigned anything to the statearr 1 and 2 yet.
>
>> Is there a specific way to reference thesestructurearrays? Any help
>> is greatly appreciated!
>
>> Thanks
>> Niv
>
> If I read it right, it sounds like state1.resvol_file_ptr is not a
> scalar, but is an array with 3 elements. Check it with n_elements
> (state1.resvol_file_ptr). Put it another way, I think what is
> happening is the same as
>
> IDL> a=intarr(3)
> IDL> print,a
>        0       0       0
> IDL> b=[1,1,1]
> IDL> a[0]=b
> IDL> print,a
>        1       1       1
>
> Which is that way because if you use an array element on the left side
> of an assignment, and assign to it an array with N elements, then N
> elements are assigned, starting at the one given on the left side.



I checked it and thats not the case. state1.resvol_file_ptr is a
scalar. I even assigned a different value:

IDL> *(*infoptr).statearr[0].resvol_file_ptr='junk'

IDL> print,*(*infoptr).statearr[0].resvol_file_ptr
junk
IDL> print,*(*infoptr).statearr[1].resvol_file_ptr
junk
IDL> print,*(*infoptr).statearr[2].resvol_file_ptr
junk

I dont' get it.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Readu, Writeu Causing Segmentation Fault
Next Topic: Issue with logrithmic z-axis... fix?

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

Current Time: Wed Oct 08 17:19:35 PDT 2025

Total time taken to generate the page: 0.00436 seconds