Is zero the same as empty?

dunbarx at aol.com dunbarx at aol.com
Mon Oct 27 14:57:55 EDT 2014


Jacque, again.


I guess my rant is not quite valid. I should have written:


on mouseUp
  put "" into b
  answer b + 1
end mouseUp






-----Original Message-----
From: Graham Samuel <livfoss at mac.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Mon, Oct 27, 2014 12:21 pm
Subject: Is zero the same as empty?


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
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 



More information about the use-livecode mailing list