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.

  • "sachagriffin" started this thread

Posts: 1,855

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

1

Wednesday, May 7th 2014, 6:35am

if( testvariable conditions fail to evaluate for string variables etc

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<action name="testme">
	if(%2,
	trace(%2 ' exists');
);
if(%2 === 'null',
	trace(%2 ,' ===null');
);

if(%2 == null,
	trace(%2 ,' ==null');
);

ifnot(%2 === null,
	trace(%2 ,' not===null');
);

ifnot(%2 == null,
	trace(%2 ,' not==null');
);

ifnot(%2,
	trace(%2 ,' not');
);
</action>


krpano.call("testme(c3,false);");
undefined
krpano.call("testme(c3,fals);");
undefined
krpano.call("testme(c3,5);");


INFO: false not===null
INFO: false not==null
INFO: false not

INFO: fals ===null
INFO: fals not==null
INFO: fals not

INFO: 5 ' exists'
INFO: 5 ===null
INFO: 5 not==null

Problems are:

Everything === null except for boolean values

if(var,... doesn't work for non numeric values

errata
z === null
"z=" not ===null
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

This post has been edited 1 times, last edit by "sachagriffin" (May 7th 2014, 7:14am)


image360

Intermediate

Posts: 207

Location: Austin, TX and Chicago, IL

Occupation: Photographer

  • Send private message

2

Thursday, May 8th 2014, 3:29am

Hi Sacha,

I think I'm seeing the same "null" behavior as perhaps you've noted.

If I go to a tour on open it loads and then switched to a "null" ending URL. If I use the browser method to go back, the tour works as intended without any more "null" links.

And I'm seeing this on old tours, built long before 1.117 and never updated, new behavior from an old tour. So I'm guessing something somewhere has changed but perhaps not in KRPano?

This one seems like it's going be a bit hard to figure out where this issue is.

Robert

  • "sachagriffin" started this thread

Posts: 1,855

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

3

Thursday, May 8th 2014, 4:03am

I'm not sure what you mean, but I think I've always had difficulties with my ifs. I just keep on trying different things until it worked. Usually when I use strings I check against a string and that's fine.
Instead of relying on null, you can use false or true and make sure your arguments are set accordingly or use other arguments to set the state. In any case, I think this situation will be resolved when Klaus has a spare moment shortly.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

image360

Intermediate

Posts: 207

Location: Austin, TX and Chicago, IL

Occupation: Photographer

  • Send private message

4

Thursday, May 8th 2014, 4:12am

Well maybe it's a different thing.

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.

Perhaps it's local, but I just had my first client note this.

So?

5

Thursday, June 26th 2014, 4:22pm

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

  • "sachagriffin" started this thread

Posts: 1,855

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

6

Monday, June 30th 2014, 8:05pm

Got it.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

This post has been edited 1 times, last edit by "sachagriffin" (Jul 1st 2014, 12:14am)