You are not logged in.

Anoril

Trainee

  • "Anoril" started this thread

Posts: 69

Location: Paris, France

Occupation: Game Developer and Photographer

  • Send private message

1

Wednesday, February 17th 2016, 9:04pm

Hotspot object initialisation and content issue with SET()

Hi all!

I ran into a weird behaviour with the set() method.

I'm making a pano where I search for a hotspot, and I store the found hotspot into a variable with set() for later use.
Because I want a clear algorithm, I initialize the variables I make use of using

Source code

1
set( storageVar, NULL );

then later in the code, if I found the hotspot I'm looking for, I store it with

Source code

1
set( storageVar, myHotspot )


I'm expecting to be able to access the hotspot attributes with

Source code

1
 ... storageVar.name ... 

but I only can trace "storageVar.name" or "null" if Im ake use of get().

This
is, in my opinion, very strange. And more over, I noticed that, if I DO
NOT initialize my variable with null, the code works as expected, I
trace the actual name of the hotspot!

Example:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 	set( secondStore, NULL );
 	for(set(i,0), i LT 1, inc(i),
		  set( storageHS, get(hotspot[%i]) );
   
 	  trace('We copied original "', hotspot[%i].name , '" object as: ',
 hotspot[%i], ' into ', storageHS, ' named "', storageHS.name, '"');

		  set( secondStore, get(storageHS) );
   
 	  trace('We then copied "', storageHS.name , '" object as: ', 
storageHS, ' into NULL initialized ', secondStore, ' named "', 
secondStore.name, '"');

      	set( thirdStore, get(storageHS) );
   
 	  trace('We last copied "', storageHS.name , '" object as: ', 
storageHS, ' into non declared ', thirdStore, ' named "', 
thirdStore.name, '"');
 	);

Result displayed:

Source code

1
2
3
INFO: We copied original "hs1" object as: [object Object] into [object Object] named "hs1"
INFO: We then copied "hs1" object as: [object Object] into NULL initialized [object Object] named "secondStore.name"
INFO: We last copied "hs1" object as: [object Object] into non declared [object Object] named "hs1"

Note on line 2 that: my storageHS is an Object (expected) but its name attribute can't be find while
on line 3, we can get the object and its attribute...

Does anyone can explain me what I'm missing?

You can have a live demo here:
http://anoril.no-ip.com/jsiTest/test.html ( xml is there: http://anoril.no-ip.com/jsiTest/test.xml )
To observe the issue, just move the view arround and click the interogation mark. :)

Regards,
« Quidquid latine dictum sit, altum sonatur »
Pentax stuff.

2

Friday, February 19th 2016, 8:06am

Hi,

sorry, but I can't reproduce your problem - neither with your example nor with self testing...

Such problem could happen when the 'secondStore' variable was FIRST defined as number or string value - by the first definition a variable get its type and on later assignments the new value will be convert to the type of the variable.

If that's the problem - you can use delete(secondStore); instead of set(secondStore,null); to avoid that problem.

Best regards,
Klaus

Anoril

Trainee

  • "Anoril" started this thread

Posts: 69

Location: Paris, France

Occupation: Game Developer and Photographer

  • Send private message

3

Sunday, February 21st 2016, 9:27pm

Hi!

Thanks for your reply, Klaus.

I'm struck that you can't reproduce! I got the error just by following the link I provided (with two different computers *wacko* )
(Win7 both, Firefox, html5:always, krpano 1.19-pr3)



Anyway, thanks for your workarround! My aim is to check against "null" to be sure I work with stuff...


As far as I understand your explaination, I suppose the system cannot set the initial type of 'null' then go crazy when casting hotspot(object) into the null type... *confused*

Best regards,

Paul
« Quidquid latine dictum sit, altum sonatur »
Pentax stuff.