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

Home » Public Forums » archive » array of structures with pointers
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
array of structures with pointers [message #84203] Mon, 06 May 2013 10:31
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I think I am having brain freeze this morning.
I want to make an array of structures, where each includes a pointer.

IDL> st = {flux:ptr_new(/all)} ;Create a structure with a pointer
IDL> st = replicate(st,20) ;I want a structure with 20 elements
IDL> *st[0].flux = 3.2 ;Assign a value to the zeroth structure element
IDL> print,*st[4].flux ;What?? - the fourth structure element also gets this value
3.20000


OK, I can figure out what is going on.

IDL> st = {flux:ptr_new(/all)} ;Create a structure with a pointer
IDL> st = replicate(st,20) ;I want a structure with 20 elements
IDL> help,st[0].flux
<Expression> POINTER = <PtrHeapVar40>
IDL> help,st[4].flux
<Expression> POINTER = <PtrHeapVar40>

Ah, so when I replicated the pointers, they all point to the same location. So when I update the value in this location once, all the pointers will be updated. So I understand what happened but how do I get what I want -- for each structure tag in the array to be an independent pointer?

Thanks, ---Wayne


P.S. I now think I want the flux tag to be a LIST(), but I would still like to know how to make a structure array with independent pointers.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL workbench & xquartz
Next Topic: Re: array of structures with pointers

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

Current Time: Fri Oct 10 08:31:44 PDT 2025

Total time taken to generate the page: 0.15473 seconds