Is zero the same as empty?
Graham Samuel
livfoss at mac.com
Mon Oct 27 12:20:18 EDT 2014
I found that if a parameter of a handler or function, or indeed a local variable, (say t1) has never had a value placed in it, then
t1 = 0
is true. I was surprised by this, since I thought all unassigned variables were rendered empty by the engine, and that empty and zero were distinct.
But in the same script
t1 = empty
is also true. Logically then, ‘empty’ is the same as ‘0’. However the statement
0 = empty
evaluates to false. Furthermore if I make sure t1 is empty by
put empty into t1
then
0 = t1
yields false.
Am I going crazy? This issue matters to me as I am comparing numeric characters with a variable which is sometimes unassigned. I see that I must always assign a value to the variable, even it that value is empty!
Is this any kind of a bug, or is it just slightly strange behaviour on the part of the engine?
Graham
More information about the use-livecode
mailing list