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

Home » Public Forums » archive » Re: help with 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: help with structure [message #70294 is a reply to message #70293] Wed, 31 March 2010 14:49 Go to previous messageGo to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Mar 31, 6:40 pm, David Fanning <n...@dfanning.com> wrote:
> Sumit writes:
>> I want to create a structure with 2 fields. The fields need to be of
>> variable length. I need to have 'n' such structures,where 'n' is
>> scalar number. To address the issue of variable length field, I create
>> pointers for each field( pointing to variable temp for initialization)
>> as shown below:
>> mystruct={l1:ptr_new(temp), l2:ptr_new(temp)}
>> I don't know how to create  copies of this structure. Replicate
>> doesn't work as I guess it creates shallow copy.
>
> What do you mean it "doesn't work"?
>
> IDL> mystruct={l1:ptr_new(temp), l2:ptr_new(temp)}
> IDL> a= replicate(mystruct, 100)
> IDL> help, a
> A               STRUCT    = -> <Anonymous> Array[100]
> IDL> a[50].l2 = Ptr_New(findgen(11))

I suppose he means that by doing that, after the replicate(), all
elements of a point to the same two heap variables. There is no way
around it, he needs to loop on the elements to set the pointer on each
one to point to something new.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: help with structure
Next Topic: Re: gripe about structures

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

Current Time: Sat Oct 11 01:57:55 PDT 2025

Total time taken to generate the page: 1.20137 seconds