Re: Structures and arrays of structures [message #93820 is a reply to message #93819] |
Fri, 28 October 2016 05:15   |
rjp23
Messages: 97 Registered: June 2010
|
Member |
|
|
Hi Markus,
Thanks for the reply.
I'm already using exe to create the structures based on the strings but it looked like I was getting one key bit wrong.
When trying to create the main structure I was effectively doing:
main=create_struct(global_struct, aus_struct, etc)
but from your example I see it should be:
main=create_struct('global_struct', global_struct, 'aus_struct', aus_struct, etc)
Thanks for the help!
Rob
On Friday, October 28, 2016 at 1:04:20 PM UTC+1, Markus Schmassmann wrote:
> On 10/28/2016 12:12 PM, wrote:
>> This has me stumped at the minute so I was hoping someone could help as I thought it SHOULD be simple.
>>
>> I have a anonymous structure in this form:
>>
>> IDL> help, global_struct
>> ** Structure <8341ea08>, 15 tags, length=138736, data length=138736, refs=1:
>> DATE FLOAT Array[2392]
>> ORIG FLOAT Array[2392]
>> FUNC FLOAT Array[2392]
>> POLY FLOAT Array[2392]
>>
>> I have a second anonymous structure in this form:
>>
>> IDL> help,aus_struct
>> ** Structure <838a5ee8>, 15 tags, length=135780, data length=135778, refs=1:
>> DATE FLOAT Array[2341]
>> ORIG FLOAT Array[2341]
>> FUNC FLOAT Array[2341]
>> POLY FLOAT Array[2341]
>>
>> I have many other structures in the same form and want them all to
>> be contained in one item so they can be easily passed into other
>> procedures, etc.
>>
>> The tag names within the structure are the same so I can use code
>> generically on any of them.
>>
>> The structure name itself is generated from a string array
>> ['global','aus', 'europe', 'us', etc]
>>
>> I can't concatenate the structures into a single as they all have
>> thesame tag names. I thought I could create an array of structures but that
>> doesn't seem to work. I wondered if I could create a structure of
>> structures? main.global_struct.dat, main.aus_struct.date, etc but can't
>> figure out how to.
>>
>> Any suggestions would be really useful.
> loc=['global', 'aus', 'europe', 'us']
> cmd='main=create_struct('
> for i=0,n_elements(loc)-1 do $
> cmd+="'"+loc[i]+"_struct',"+loc[i]+"_struct,"
> cmd=strmid(cmd,0,strlen(cmd)-1)+")"
> void=execute(cmd)
>
> i hope that helps, Markus
|
|
|