Hello!
I'm sorry to bother you with what I suppose is something everyone should know… but how do I access an attribute has its name stored in another variable?
Suppose I have a xml element with the descriptions of my three hotspots nm1, nm2 and nm3, to be shown when I hover over them.
<description
nm1="kitchen"
nm2="bedroom"
nm3="living room"...>
On the hotspot definition, I call the "find description()" with the onhover.
<hotspot name="nm1", onhover="find_description()" ...>
If I define the action find_description as such:
<action name="find_description">
txtadd(hovertext,"description.", get(name()); <!-- get(name) gives me the name of the hotspot I hover, i.e. nm1 -->
trace(name);
trace(hovertext);
trace(get(hovertext));
showtext(get(hovertext));
</action>
trace(name) gives me the hotspot name (i.e. nm1), which is ok.
Trace (hovertext) gives me "desription.nm1".
Trace(get(hovertext)) gives me "kitchen" and that is ok.
But showtext doesn't work like trace, showtext(get(hovertext)) still shows me "description.nm1".
Is there any straightforward way to solve the problem? The only way I could think of was quite clumsy, to redefine the action to call another action act2:
<action name="find_description"> txtadd(hovertext,"description.", get(name()); act2(get(hovertext)) </action>
<action name="act2"> showtext(get(%1)) </action>
This, of course, substituted desription.nm1 into %1, transforming get(%1) into get(description.nm1), which, obviously, showed "kitchen". It made it possible to apply get twice. Unfortunately, using just showtext(get(get(hovertext)) didn't work, it showed Null.
But it doubled the number of neccesary actions, it makes the code very unreadable.
Thank you!