Re: structure access using strings for tag-names [message #43421] |
Mon, 11 April 2005 07:02  |
Thomas Pfaff
Messages: 15 Registered: April 2005
|
Junior Member |
|
|
> Try this out:
>
> ;get list of tag names
> tagnamelist=tag_names(!P)
>
> ;find which tag has the name "MULTI"
> tagindex=where(tagnamelist EQ 'MULTI')
>
> ;access the structure
> print,!p.(tagindex)
>
> You can use struct.(0), struct.(1) etc. to access the values
> in the first, second,... tag.
>
> --Paolo
That sounds fine. I had read about the access method using struct.(i)
but I had missed a possibility to get the index from the name.
By the way. Is anyone using structures this way, or do you prefer
something similar to the hash_table class, which I found on RSI's website.
Or do you use even different things for associative storage?
Thanks a lot,
Thomas
|
|
|
Re: structure access using strings for tag-names [message #43462 is a reply to message #43421] |
Wed, 13 April 2005 14:12   |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Mon, 11 Apr 2005 16:02:02 +0200, Thomas Pfaff wrote:
>> Try this out:
>>
>> ;get list of tag names
>> tagnamelist=tag_names(!P)
>>
>> ;find which tag has the name "MULTI"
>> tagindex=where(tagnamelist EQ 'MULTI')
>>
>> ;access the structure
>> print,!p.(tagindex)
>>
>> You can use struct.(0), struct.(1) etc. to access the values
>> in the first, second,... tag.
>>
>> --Paolo
>
> That sounds fine. I had read about the access method using struct.(i)
> but I had missed a possibility to get the index from the name.
>
> By the way. Is anyone using structures this way, or do you prefer
> something similar to the hash_table class, which I found on RSI's website.
> Or do you use even different things for associative storage?
I would prefer a fast built-in hash type, and I would prefer to be
able to use that type, in place of a normal struct, as the underlying
basis of objects. Then I could extend class structure members at
runtime, and do all manner of things which are convenient with a hash
but inconvenient with a fixed, predefined structure.
Maybe it's just the Perl hacker in me.
JD
|
|
|
|
Re: structure access using strings for tag-names [message #43514 is a reply to message #43462] |
Mon, 18 April 2005 01:31  |
Thomas Pfaff
Messages: 15 Registered: April 2005
|
Junior Member |
|
|
> I would prefer a fast built-in hash type, and I would prefer to be
> able to use that type, in place of a normal struct, as the underlying
> basis of objects. Then I could extend class structure members at
> runtime, and do all manner of things which are convenient with a hash
> but inconvenient with a fixed, predefined structure.
>
> Maybe it's just the Perl hacker in me.
>
> JD
>
The python hacker in me violently agreed on the first part (A fast
builtin list-type would be the next thing on my wishlist :-)). However I
haven't seen any programming language that allows dynamic addition of
class members. Wouldn't that in parts violate the concepts of data
encapsulation and information hiding, if you could add and remove class
members at will? Then I would first like to have public class members.
Thomas
|
|
|