Re: Named and Anonymous structures ? [message #5113 is a reply to message #5111] |
Mon, 09 October 1995 00:00  |
steinhh
Messages: 260 Registered: June 1994
|
Senior Member |
|
|
In article <DG1EBF.FrJ@rivm.nl>, robk@rivm.nl (Rob Koopman) writes:
|>
[snip]
|> struc3 = { made_to_measure_struc,
|> first_array: fltarr(number_of_rows, 10), $ ; dynamic
|> another_arr: intarr(number_of_rows, 25), $ ; arrays
|> };
|>
|> array_of_struc3s = replicate({file_specific_struc},struc2.nmbr_o_records)
|> readu,unit,array_of_struc3s
|> free_lun,unit
|> struc_back_to_main = { pret_a_porter_struc $
|> first: struc1 , $
|> secnd: struc2 , $
|> (3): ...... , $
|> (4): ...... , $
|> fifth: array_of_struc3s , $
|> (6): ...... $
|> };
|> end
|> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;
|>
|>
|> But here's my problem. I can make "struc_back_to_main" an anonymous
|> structure, and this allows me to read files with different "nmr_o_records"
|> but as soon as there's a file with a different "number_of_rows" I'm in
|> trouble: "struc3" should then also be anonymous, but unfortunately
|> anonymous structures cannot be part of other anonymous structures
|> as I've just found out after writing several main programs that call
|> this procedure :-(
|> Once this struc_back_to_main is passed to the caller, struc3
|> can be destroyed, as far as I'm concerned, but the only way I've
|> managed to do that, is by exiting the IDL session.
|>
|> Is there another way to destroy named structures?
As far as I can tell (haven't had too much experience with version 4.0),
there's only one solution (other than rewriting your code substantially
with your own storage allocation system):
Use:
dymmy=execute( $
"struc3={made_to_measure_" + trim(number_of_rows) + "," +$
"first_array: fltarr(number_of_rows, 10),"+ $ ; dynamic
"another_arr: intarr(number_of_rows, 25) }" $ ; arrays
)
where trim(N) \equiv strcompress(string(N),/remove_all)
This will give you named structures e.g., "MADE_TO_MEASURE_100"
for storing 100 rows, and "...._200" for storing 200 rows.
Stein Vidar
|
|
|