Structure assign question [message #28164] |
Wed, 21 November 2001 10:47 |
Paul van Delst
Messages: 364 Registered: March 1997
|
Senior Member |
|
|
Hey there,
This is probably a bit of a brain dead question, but I haven't found any satisfaction poring
over the online help, so here goes....
I have begun my foray into objects in IDL (well, .. translating my OOP-y Fortran 90 code into
IDLspeak). Anyway, I have the following object/structure definition procedure:
PRO PDdata__define
PDcommon_definition
COMMON PDcommon
data_structure = { PDdata, n_profiles : IO_INT_TYPE, $
profile : PTR_NEW() }
END ; PRO PDdata__define
nice and simple.
In my PDdata::Read method, which fills the above data structure/object, I have the following:
; -- Create the top level PDdata structure
self.n_profiles = n_profiles
self.profile = PTR_NEW( REPLICATE( { PDprofile }, n_profiles ) )
; -----------------------
; Each profile dimension
; -----------------------
; -- Initialise arrays
n_layers = LONARR( n_profiles ) & k = 0L
n_absorbers = LONARR( n_profiles ) & j = 0L
; -- Loop over profiles
FOR m = 0L, n_profiles - 1L DO BEGIN
READU, file_id, k, j
profile = PDprofile_create( k, j )
(*self.profile)[ m ] = profile
n_layers[ m ] = k
n_absorbers[ m ] = j
ENDFOR
My question relates to the PDprofile_create() function. It returns a named structure (name is
"PDprofile"). This structure is replete with various other (named) structures and pointers etc.
hence the separate function. I then assign this structure to the required element of the data
object, self.profile :
(*self.profile)[ m ] = profile
Here is where the question may or may not be considered brain-dead. Is this sort of (named)
structure assign o.k., i.e. does the entire heirarchy of pointers and structures within the
"profile" structure variable get assigned (it appears so at this point but I'm still testing).
And am I creating a separate instance of the PDprofile structure or am I confusing the pointer
with what the pointer is pointing at (get it?).
Can you tell I'm confused?
Any insights appreciated.
paulv
--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
|
|
|