[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
indexing over structure tags
- Subject: indexing over structure tags
- From: Randall Skelton <rhskelto(at)atm.ox.ac.uk>
- Date: Thu, 19 Apr 2001 17:28:19 +0100
- Newsgroups: comp.lang.idl-pvwave
- Organization: Oxford University, England
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:24614
Hello,
Imagine someone has a structure of structures...
; define the basic structure for each
sm_struc = {basic_struct, comment: ' ', values: fltarr(nlev)}
; define the large structure
data = {big_struct, so4: sm_struc, co2: sm_struc, hcl: sm_struc}
The IDL manual describes how to make an array of the tags in a structure
using:
; get the names of the tags
names = tag_names(data)
so that names = [so4, co2, hcl].
That is all fine. But is it possible to index over the tag names with a
for-loop?
i.e. for i=0, n_elements(names)-1 do data.names[i].values = i
^^^^^^^^^^^^^^^^^^^^
where IDL determines what the appropriate label 'data.name[i].values' is.
Thanks,
Randall