You are not logged in.

Adelphos

Beginner

  • "Adelphos" started this thread

Posts: 3

Location: Finland

  • Send private message

1

Wednesday, January 11th 2012, 3:54pm

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.

Source code

1
<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.

Source code

1
<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.

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

2

Wednesday, January 11th 2012, 4:13pm

try:

Source code

1
2
3
4
5
<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:

Source code

1
2
3
4
<hotspot name="hs-1934" description="Description of the hs"  style="style_hs" onhover="show_text();" />
<action name="show_text()">
showtext(get(description));
</action>

Adelphos

Beginner

  • "Adelphos" started this thread

Posts: 3

Location: Finland

  • Send private message

3

Wednesday, January 11th 2012, 4:28pm

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.

4

Thursday, January 12th 2012, 5:17pm

Hi,

this would work:

Source code

1
copy(var_content, get(var_with_varname));


as example:

Source code

1
2
3
4
5
6
7
<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