comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Defining structuretype during runtime?? QUESTION!! (no reply)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Defining structuretype during runtime?? QUESTION!! (no reply) [message #5025 is a reply to message #4955] Mon, 11 September 1995 00:00 Go to previous messageGo to previous message
Thomas A McGlynn is currently offline  Thomas A McGlynn
Messages: 3
Registered: August 1995
Junior Member
jackel@canlon.physics.uwo.ca (Brian Jackel) wrote:
> In article <42n2sj$dhk@news.tuwien.ac.at> "Christian Oehreneder
> (PHOTO-Dissertand)" <coehrene> writes:
>
>> MY PROBLEM AGAIN:
>
>>> Schalom!
>>>
>>> I want to store variables of different type together in structure. The
>>> type of each structure elemet is defined DURING RUNTIME.
>>> How can I create a structure, whos tag types and tag number are defined
>>> at runtime?
>>>
>>> Thanks in advance
>>> Chris
>>>
>
> Have you considered using the intrinsic function "CREATE_STRUCT"?
> Note that this will make named or anonymous structures.

There's a problem using CREATE_STRUCT if you don't know the number of
elements in the structure in advance. It requires a separate argument
for each value. I've built and seen other versions of functions
that return structures where the both the names and values can be
passed in as arrays. This gives the greatest flexibility in defining
structures on the fly. E.g., one can call:

str = mrd_struct(['a','b','c'],['0.', '1L', 'intarr(30,30)'])

to create a structure with three elements, a scalar real, a scalar long
and a 30x30 integer array. Using create_struct directly you've got problems
if you don't know the number of elements in the structure.

You can implement this internally using the IDL create_struct to build
the structure by concatenation, the
execute function (for short structures), or by dynamically compiling
functions defining the appropriate structure.

Good luck.

Tom McGlynn
Goddard Space Flight Center
mcglynn@grossc.gsfc.nasa.gov
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Named and Anonymous structures ?
Next Topic: wavelet spectra help

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:29:56 PDT 2025

Total time taken to generate the page: 0.47931 seconds