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

Home » Public Forums » archive » Re: Structure field concatenation
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: Structure field concatenation [message #21581 is a reply to message #21579] Tue, 05 September 2000 05:47 Go to previous messageGo to previous message
Amara Graps is currently offline  Amara Graps
Messages: 24
Registered: June 1996
Junior Member
Ben Tupper wrote:
>
> Hello and thanks to all,
>
> I guess I'm headed toward pointers as fields.

There's alot of discussions here about structures and pointers
as fields inside of the structures. I'm learning alot, but still
having some trouble. I have made my best attempt to getting a
structure-with-pointer array concatenation to work properly,
and I've not been successful yet.

Everything works fine up to the point that I concatenate the array,
then I lose the previous definition of the pointer. Is there a
pointer cleanup that I should be doing?

My test code is the following:

;-------begin test code
;Create an anonymous structure
thisstruc = {orbit:'',freq:ptr_new(/allocate_heap)}

;Create an array of anonymous structure
periodcube = replicate(thisstruc,1)

;Assign the structure values
periodcube(0).orbit = 'G2'
*periodcube(0).freq=DINDGEN(100) ;first pointer array is len 100

;set a variable to the pointer
test1 = *periodcube[0].freq
;Take a look
help, test1 ;(it's len 100, and OK)

;Update the structure by creating a temporary structure like the
;original, and then concantenating
tempperiod = thisstruc
;Assign values to the structure
tempperiod.orbit='C3'
*tempperiod.freq = DINDGEN(50)+50 ;this pointer array is len 50

;Set a variable to the pointer
test2 = *tempperiod.freq
;Take a look
help, test2 ;(it's len 50, and OK)

;Concatenating (here is where the problem begins)
new = [periodcube,tempperiod]

;Set variables to the pointers in the structure
freq1 = *new[0].freq
freq2 = *new[1].freq

;Take a look
help, freq1, freq2 ;WHY ARE FREQ1 FREQ2 THE SAME?
help, *new[0].freq,*new[1].freq ;BOTH LENGTH 50.. WHY?
help, new[0].orbit, new[1].orbit ;THESE STRINGS ARE OK THOUGH

END
;---end test code

Can anyone give me a hint about why the second pointer is overwriting
the definition of the first pointer?

Thanks very much, in advance,
Amara


--

************************************************************ ***
Amara Graps | Max-Planck-Institut fuer Kernphysik
Interplanetary Dust Group | Saupfercheckweg 1
+49-6221-516-543 | 69117 Heidelberg, GERMANY
* http://galileo.mpi-hd.mpg.de/~graps
************************************************************ ***
"Never fight an inanimate object." - P. J. O'Rourke
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: NetCDF file object
Next Topic: Gettng a widget screenshot?

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

Current Time: Wed Oct 08 16:21:40 PDT 2025

Total time taken to generate the page: 0.00340 seconds