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 #5049 is a reply to message #4955] Thu, 07 September 1995 00:00 Go to previous messageGo to previous message
Juergen Paff is currently offline  Juergen Paff
Messages: 3
Registered: September 1995
Junior Member
"Christian Oehreneder (PHOTO-Dissertand)" <coehrene> wrote:

>> Schalom!
>>
Dto.
>> 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
>>
>
I'm not shure I understood completly what you're up for, but here are some
remarks that may help:
(You didn't mention what you're using, Wave or IDL. But I assume the hints
below are valis for both systems. They at least hold for Wave)

1) You cannot redifine a struct that has a name. Fortunately, there are
unnamed structures. They can be defined at will, f.i.

my_struct={ , tagname1: value_of_type_tagtype1, $
tagname2: value_of_type_tagtype2, $
tagname3: value_of_type_tagtype3, $
; and so on.
}
2) As you learn (name and) type only at run time, you might want to use the
command

return_status=execute(string_argument)

string_argument has to be a string that conains a command that is valid at
run time. Consider the following situation:
The type of tag1 is stored in string type1 , and the name in string name1 ,
and analogous for tag2, tag3. Consider further that values of the appropriate
time are stored in variables with names value1 , value2 , and value3 .
Then you could use the code:
status=execute( $
"'my_struct={ , '+name1+': '+value1+', '+ $
name2+': '+value2+', '+ $
name3+': '+value3+' }' "
At run time, this would fill in the contents of the string variables, and then
execute the resulting command.
If you don't know the values yet, you could use a default initialization:
"'my_struct={ , '+name1+': '+type1+'(0), '+ $
'+name2+': '+type2+'(0), '+ $
'+name3+': '+type3+'(0) }' "
Note: The above initialization with '0' may cause problems if type is, f. i.,
complex. If things like this can happen, you need to catch them with
some ifs.
Okay, looks a little messy. However, this 'execute' command is incredibly
helpful. You generate the code you need at runtime by glueing together
the appropriate strings.
Note: There may be some errors in the above code, I couldn't test it.
Hope you got the gist.

In case I misunderstood you completely: plse send me mail.
Good luck Juergen
[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 15:18:02 PDT 2025

Total time taken to generate the page: 3.03462 seconds