#Null is not translated to null

Just starting out? Need help? Post your questions and find answers here.
the.weavster
Posts: 229
Joined: Sat Mar 01, 2014 3:02 pm

#Null is not translated to null

Post by the.weavster »

Code: Select all

js = #Null
gets translated to

Code: Select all

var v_js = 0;
rather than

Code: Select all

var v_js = null;
I think this might have an implication for the inference engine, for example if you did something like this:

Code: Select all

 
js = #Null
!v_js = {"FirstName":"John","LastName":"Bull"};
it would get translated to this:

Code: Select all

 
var v_js = 0;
v_js = {"FirstName":"John","LastName":"Bull"};
I think the fact we've just changed the data type of the variable might cause Firefox to kick our compiled code back down to the interpreter.
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: #Null is not translated to null

Post by Fred »

While I understand you point, #Null in SB is 0, not null. If you need the null value in custom JS code, better write it in inlined JS !
the.weavster
Posts: 229
Joined: Sat Mar 01, 2014 3:02 pm

Re: #Null is not translated to null

Post by the.weavster »

Ah, I didn't realise this would work :oops: :

Code: Select all

!var v_sayhello = "Hello, World!";
Debug sayhello
I thought I had to initialise the variable in SpiderBasic and only then would it be available for passing back and forth with JS using the v_ prefix.
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: #Null is not translated to null

Post by Fred »

Would not work with EnableExplicit though.
Post Reply