Variable name in variable

  • Hi.

    I'm having problems with variables. I have a variable name in a variable, and I just can't find any way to get the original value through the two variables. Confusing? Well, here's a simplified example.

    Code
    <hotspot name="hs-1934" onloaded="set(desc-hs-1934, 'Description of the hs')"  style="style_hs" onhover="showtext();" />


    Next, I would like to have only one action, like this.

    Code
    <action name="showtext">showtext(get(desc-get(name)));</action>


    But it doesn't work and it seems to me that I cannot have get inside get? Is there another way to resolve the original content of the variable? I don't want to write thousand actions just for the showtext-action.

  • try:

    Code
    <hotspot name="hs-1934" onloaded="set(desc-hs-1934, 'Description of the hs')"  style="style_hs" onhover="show_text();" />
    <action name="show_text()">
    txtadd(tmp, 'desc-', get(name));
    showtext(get(tmp));
    </action>

    alsoo dont name your actions the same as krpano build in functions

    Alsoo I dont know why you use onloaded. This would be better:

    Code
    <hotspot name="hs-1934" description="Description of the hs"  style="style_hs" onhover="show_text();" />
    <action name="show_text()">
    showtext(get(description));
    </action>
  • It was just an example which I wrote for this topic. Well, your first example just shows the name of the variable, not the value. I've tried that one and that's where is my problem. I can't figure out the value of the variable through another variable. But thanks for the second code, didn't realize there's a description itself. But still, how to get a variable through another variable? Any other programming language I know can do that.

  • Hi,

    this would work:

    Code
    copy(var_content, get(var_with_varname));

    as example:

    Code
    <hotspot name="hs-1934" onloaded="set(desc-hs-1934, 'Description of the hs')"  style="style_hs" onhover="show_text();" ... />
    
    
    <action name="show_text">
    txtadd(var_with_varname, 'desc-', get(name));
    copy(var_content, get(var_with_varname));
    showtext(get(var_content));
    </action>

    best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!