Hi,
Everything === null except for boolean values
The if() action is working as it should in your case.
Here a slightly re-arranged version of your 'testme' action with more detailed output - this should better explain how the if action is working:
|
Source code
|
1
2
3
4
5
6
7
8
|
<action name="testme">
if (%2, trace(%2 ,' - exists as variable or has a value that is not false'); );
ifnot(%2, trace(%2 ,' - does not exists as variable or the value of it is false'); );
if (%2 === null, trace(%2 ,' - is not a variable'); );
ifnot(%2 === null, trace(%2 ,' - is a variable'); );
if (%2 == null, trace(%2 ,' - is null'); );
ifnot(%2 == null, trace(%2 ,' - is not the same as null'); );
</action>
|
When calling:
|
Source code
|
1
2
3
|
testme(c3,false);
testme(c3,fals);
testme(c3,5);
|
this will be the result:
|
Source code
|
1
2
3
4
5
6
7
8
9
|
INFO: false - does not exists as variable or the value of it is false
INFO: false - is a variable
INFO: false - is not the same as null
INFO: fals - does not exists as variable or the value of it is false
INFO: fals - is not a variable
INFO: fals - is not the same as null
INFO: 5 - exists as variable or has a value that is not false
INFO: 5 - is not a variable
INFO: 5 - is not the same as null
|
if(var,... doesn't work for non numeric values
There is basically a two-step check here - first the if() action checks if there
exists a variable named 'var' - and if one
exists, it will check the value of it.
This is done due a limitation of the current action system - the action system itself is 'typeless' - that means there is no difference between a string/text or a variable name. The quote characters are only used to 'quote' a given parameter from parsing other key-characters (like comma or brackets), but don't have any influence to the variable/value type itself.
To check directly if a variable
exists or not, the '===' or '!==' operators need to be used (btw - true and false are internally variables, so testing if they are variables will succeed).
There is currently also another limitation related to checking if a variable
exists or has the value null - internally the get() action, which gets the value of a variable always returns either the value of the variable or null - so it's currently not possible to differ between a not-defined-variable and a variable that has null as value, because in both cases null will be returned.
But this one limitation will be fixed in the next release - then the get() action will return 'undefined' for a not defined variable and this will allow the if() action to differ between not defined variables and variables with the value null.
I have made a special if() test case here for testing this and other if() situations:
http://krpano.com/krpano.html?xml=exampl…ts/if-tests.xml
xml:
http://krpano.com/examples/actiontests/if-tests.xml
In the current 1.17 version 3 tests will fail, but in the next 1.18 version all tests will pass.
Btw - I'm of course also considering a more advanced script system without such limitations, but that can't be made to be compatible to the current system, so this is more something for a future krpano '2.0' version.
When I load a tour, some of them, it loads, but then switches to a "null" link. This is simply with using the default VTour droplet results.
Sorry, but I have no idea what you mean here and I doubt that this would be related to the if() action...
Best regards,
Klaus