Named and Anonymous structures ? [message #5121] |
Fri, 06 October 1995 00:00  |
robk
Messages: 2 Registered: October 1995
|
Junior Member |
|
|
I could use a refreshing idea to get me out of a problem related to
structures in IDL:
I must read binary data with variable format and had no problem to
write an extraction programme that reads one file per IDL session,
but my main problem now is that named structures cannot be changed once
defined, and at the same time, anonymous structures (which can be
changed) cannot be part of other anonymous structures.
At first I wrote a procedure that works fine on one file:
Below is a simplified version, reduced to the essential elements of
the problem.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;
PRO an_extraction.pro, struc_back_to_main
openr,unit,'huge_satellite_data_file_with_complex_structure' ,/get_lun
struc1 = {named_struc , $ ; first part of data, always
(1): 0 , $ ; same format
(2): 0L , $
(...): 0. , $
(5): string(0) $
} ;
readu,unit,struc1
struc2 = {another_named_struc , $
(1): 0L , $ ; always same format
(2): 0L , $
(...): 0. , $
number_of_rows:0 , $
nmbr_o_records:0 $
};
readu,unit,struc2 ; get values for number_of_rows and nmbr_o_records
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?
Can the TEMPORARY function help me out of this trouble?
I have an IDL version (4..) that's newer than my manual (3.1) , are there
new tricks that could help me out, e.g. "C"-style pointers, things like
"malloc" etc??
Any help is appreciated, thank you in advance,
_/_/_/ _/
_/ _/ _/
_/_/_/ _/_/ _/_/
_/ _/ _/ _/ _/ _/ Koopman, Air Research Lab., RIVM,The Netherlands
_/ _/ _/_/ _/_/
|
|
|