You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,115

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

1

Friday, May 17th 2019, 10:51am

get(calc());

Hi,

i think it would be great to have a syntax option to use calc in get actions like:

maybe something like this?

Source code

1
copy(bla, get(calc('bla' + blaaa_ + i)));

so we can do this in one line:

Source code

1
2
        set(stickietitle, calc:'global.data[stickie_close].content');
        copy(stickietitle,get(stickietitle));


i might be wrong or confused, like normal fridays ;-), but i think this is not possible yet in one line, is it?


Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

2

Friday, May 17th 2019, 11:20am

hi tuur...
i wanted to answer.. but then i got confused of what you want to do .)

but for a quick one... it might be that calc needs a semicolon
copy(bla, get(calc('bla' + blaaa_ + i);));

index :)

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,115

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

3

Friday, May 17th 2019, 2:34pm

get(calc)); -- > solved

Ahh yes that works!

like

Source code

1
copy(layer[result].html, get(calc('cars.type' + %1)));


the extra semicolon is also not needed...
Great!
Saves some lines!
Little example here: https://www.virtualtuur.com/krpano/get/1/

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    <action name="DoResult_1">
        set(res, calc:'cars.type' + %1);
        copy(res,get(res));
        set(layer[result].html, calc:res);
    </action>
    
    <action name="DoResult_2">
        set(res, calc:'cars.type' + %1);
        calc(layer[result].html, get(res));
    </action>

    <action name="DoResult_3">
        copy(layer[result].html, get(calc('cars.type' + %1)));
    </action>

    <action name="DoResult_4">
        copy(bla, get(calc('cars.type' + %1)));
        set(layer[result].html, calc:'i love ' + bla);
    </action>


I was looking for DoResult_3 and DoResult_4.
Would be even more great to have DoResult_4 possible in one line.



Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

4

Friday, May 17th 2019, 3:43pm

hm, i never use calc: in action code, only calc()

does that work ?
set(res, calc:'cars.type' + %1);

i thought calc: is for attributes only
<element attr="calc:1+2" />

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,115

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

5

Friday, May 17th 2019, 4:10pm

Hi index,

Yes that works. I use it a lot.

Source code

1
set(res, calc:'cars.type' + %1);


Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

6

Monday, May 20th 2019, 11:26am

I think this way is the best:

Source code

1
calc(layer[result].html, 'i love ' + %1);



Source code

1
calc(layer[result].html, carstype + %1);



set(stickietitle, calc:'global.data[stickie_close].content');
copy(stickietitle,get(stickietitle));

Source code

1
calc(stickietitle, 'data:stickie_close');

or

Source code

1
txtadd(stickietitle,'data:stickie_close');

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,115

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

7

Monday, May 20th 2019, 12:25pm

Hi,

Thanks for thinking along!
but not sure where you go now...

this line is very powerful to me:

Source code

1
copy(layer[result].html, get(calc('cars.type' + %1)));


would be great if we could do this also in one line:

Source code

1
2
        copy(bla, get(calc('cars.type' + %1)));
        set(layer[result].html, calc:'i love ' + bla);



Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

a.pu

Trainee

Posts: 70

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

8

Tuesday, May 21st 2019, 11:06am

Hi,

this line is very powerful to me:

Source code

1
copy(layer[result].html, get(calc('cars.type' + %1)));



copy(layer[result].html, get(cars.type%1));

should work too

or even copy(layer[result].html, cars.type%1);

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,115

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

9

Tuesday, May 21st 2019, 11:24am

Hi,

yes i know
But that is not what i need.
I want to do the calc in the get.
Maybe the example line is too simple.

I want more like:

Source code

1
2
copy(bla, get(calc('cars.type' + layer[blaat].id)));
copy(layer[result].html, calc:'i love ' + bla);


most ideal this in one line of code:

Source code

1
2
copy(bla, get(calc('cars.type' + layer[blaat].id)));
set(layer[result].html, calc:'i love ' + bla);


So i think i like to do something like:

Source code

1
copy(layer[result].html, calc('i love ' + get(calc('cars.type' + layer[blaat].id))));


... is not gonna work i'm afraid.

let's try:

Source code

1
calc(layer[result].html, 'i love ' + get(calc('cars.type' + layer[blaat].id))); 

...
nope..
Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

This post has been edited 1 times, last edit by "Tuur" (May 21st 2019, 11:39am)


a.pu

Trainee

Posts: 70

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

10

Tuesday, May 21st 2019, 12:10pm

Hi,

most ideal this in one line of code:

Source code

1
2
copy(bla, get(calc('cars.type' + layer[blaat].id)));
set(layer[result].html, calc:'i love ' + bla);



this statement should already work, shouldn't it?

it means you calc some variable name, then you get another variable name stored in first varialbe
then you copy second variable value somewhere

I use sometimes statements like this one
copy(layer[breadcrumb].html, calc('catalog.title' + lang[get(current_language)].suffix));

works good.

I wonder if still miss your point :)

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,115

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

11

Tuesday, May 21st 2019, 12:20pm

Sorry, yes.. almost right..
But..
This line is most clear i think

Source code

1
copy(layer[result].html, calc('i love ' + get(calc('cars.type' + layer[blaat].id))));


So in the get(calc i like to get the value of cars.type14 but 14 is the id of a layer in this example.
I want to have some text and add text by to get the value of the 2things that are combined in the calc.

I might be stupid though, confused for sure now.. haha
Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

a.pu

Trainee

Posts: 70

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

12

Tuesday, May 21st 2019, 12:30pm

copy(layer[result].html, calc('i love ' + get(calc('cars.type' + layer[blaat].id))));


sure that's more advanced kung Fu *g*

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,115

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

13

Tuesday, May 21st 2019, 12:37pm

haha..

i think to use get inside calc is just not possible.
And in this case use: calc in get in calc.. is too much.. i can imagine.. also not supriced though.

And.. i learned some.

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

14

Tuesday, May 21st 2019, 1:26pm

Ahh yes that works!

like

Source code

1
copy(layer[result].html, get(calc('cars.type' + %1)));


the extra semicolon is also not needed...
Great!
Saves some lines!
Little example here: https://www.virtualtuur.com/krpano/get/1/

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
        set(res, calc:'cars.type' + %1);
        copy(res,get(res));
        set(layer[result].html, calc:res);
    
    
    
        set(res, calc:'cars.type' + %1);
        calc(layer[result].html, get(res));
    

    
        copy(layer[result].html, get(calc('cars.type' + %1)));
    

    
        copy(bla, get(calc('cars.type' + %1)));
        set(layer[result].html, calc:'i love ' + bla);


I was looking for DoResult_3 and DoResult_4.
Would be even more great to have DoResult_4 possible in one line.



Tuur *thumbsup*
A good example to understand how it works! *thumbsup* *thumbsup* *thumbsup*

15

Tuesday, May 21st 2019, 2:09pm

just tested:
get() in calc() really does not work, this is a limitation...

but normally you dont need it, bc calc() resolves variables like get() and copy()
also in trace(), debug(), error() etc you do not need get()

set(a,'hello');

set(b, get(a)); trace(b); // hello
copy(b, a); trace(b); // hello

calc(b, a); trace(b); // hello
calc(b, a + ' man'); trace(b); // hello man

trace(get(a)); // hello
trace(a); // hello

This post has been edited 1 times, last edit by "indexofrefraction" (May 21st 2019, 2:19pm)


Tuur

Sage

  • "Tuur" started this thread

Posts: 3,115

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

16

Tuesday, May 21st 2019, 2:36pm

Thanks index for confirmation about the get!

My calc: and get() is mostly old habits i'm afraid.
I'll try to be more consistent.


Tuur *thumbsup*
(now having a little fight with the private scope..haha .. addicted to krpano)
http://www.virtualtuur.com
Skype:studiotuur