Sie sind nicht angemeldet.

perspixe

Schüler

  • »perspixe« ist der Autor dieses Themas

Beiträge: 64

Wohnort: Bologna, Italia, Vancouver, BC

  • Nachricht senden

1

Dienstag, 11. Juli 2017, 12:39

Object variable issue

I
Not sure if I use the right words for what things are.
I have an object constructed that way:
myvar.h
myvar[i].v
myvar[i].fov

Then I want to save a temporary version of all myvar to be able to recall it later.

To save in temp:
set (myvarTEMP, get(myvar));

then myvar is modified but at some point I want to recall to original myvar so I do:
set (myvar, get(myvarTEMP));

The saving works.
The recall doesn't. In fact it looks like myvarTEMP is in fact a reference to myvar so all the modifications done to myvar were updated for myvarTEMP (bad way to say it as it is a reference I suppose). So when I call back the old values they were actually the mod ones.
I need the temp not to be a reference but a completely independent variable/object.

I tried search and find ways around this.
It feels like some basic thing I don't understand.

Thanks for help anyone.

Beiträge: 1 117

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : the cms4vr owner

  • Nachricht senden

2

Dienstag, 11. Juli 2017, 15:15

Hi

I check your problem by this small actions:

Quellcode

1
2
3
4
5
6
7
8
9
10
<action name="checkVartemp" autorun="preinit">    
set(myvar, 00001);    
trace('1: ',get(myvar));    
set(myvarTEMP, get(myvar));    
trace('2: ',get(myvar),' temp: ',get(myvarTEMP));    
set(myvar, 00002);    
trace('3: ',get(myvar));    
set(myvar, get(myvarTEMP));    
trace('4: ',get(myvar));  
</action>



and I have this data:

Quellcode

1
2
3
4
INFO: 1: 00001  
INFO: 2: 00001 temp: 00001  
INFO: 3: 00002  
INFO: 4: 00001



It works...

Best regards
Piotr
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

perspixe

Schüler

  • »perspixe« ist der Autor dieses Themas

Beiträge: 64

Wohnort: Bologna, Italia, Vancouver, BC

  • Nachricht senden

3

Donnerstag, 13. Juli 2017, 14:58

Hi Piotr
Yes it works with a simple variable. But it seems that if the variable is an array, then a copy of it is a reference...
I can't rechceck right now sorry. Later tonight.

4

Donnerstag, 13. Juli 2017, 22:55

Try with:

Quellcode

1
copy(myvarTEMP, myvar);

Beiträge: 1 117

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : the cms4vr owner

  • Nachricht senden

5

Freitag, 14. Juli 2017, 14:51

Hi

copy(myvarTEMP, myvar); == set(myvarTEMP, get(myvar)); - The effect is the same ;-)


Piotr
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*