[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Structure field concatenation



Hello,

I know that this has been a subject of some discussion recently... but
I'm still not on firm footing on the best method of changing the size of
an anonymous structure's fields (i.e. I want to increase or decrease the
size of a field).   The code below shows an example of how I do it now:
creating a new structure with the appropriately sized fields.  Is there
a better method?

;++++++++++++ START
PRO Concatenate_Str_Fields

D = {A:Indgen(12), B:Indgen(12)}            ;define a dummy structure

Help, D, /STR

Tags = Tag_Names(D)

NewD = Create_Struct(Tags[0], [D.(0), Indgen(10)])    ;define the new
structure with amended field

For i = 1, N_ELEMENTS(Tags) -1 Do $            ;for each tag recreate
the structure
 NewD = Create_Struct( NewD, Tags[i],[D.(i), Indgen(10)] )

Help, NewD, /STR

END

;--------------------END

Thanks,

Ben

BTW:   I don't want to steer the discourse toward a scandalous sidebar
discussion, but...  I'm wrestling with this because a shrimp starts out
as a male and then ends up as a female a few years later.   I'm working
with a database that has the shrimp broken down into records by sex...
but I need to add new records for aggregate sex (that is the sum of
males, transitionals, females,...)   I never thought IDL programming
could be so titillating.

--
Ben Tupper
248 Lower Round Pond Road
POB 106
Bristol, ME 04539

Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net