Is zero the same as empty?

dunbarx at dunbarx at
Mon Oct 27 16:10:49 EDT 2014


You can simply declare a variable, ostensibly empty, and the engine will watch your back if you try to add something to it. But you cannot both declare and add in the same line of code. So there is another level of declaration, perhaps because it occurs in the very same line as the test arithmetic, that breaks:

on mouseUp
put b + 3
end mouseUp

This is similar to but "below" the extra level of evaluation that we know as a "do"  construction. It is deeper, closer to the heart of the engine, perhaps, that was never addressed (or ignored for other reasons)? Because this does not work, though one might think it should:

on mouseUp
   do "put b + 3"
end mouseUp


-----Original Message-----
From: J. Landman Gay <jacque at>
To: How to use LiveCode <use-livecode at>
Sent: Mon, Oct 27, 2014 3:16 pm
Subject: Re: Is zero the same as empty?

On 10/27/2014, 1:55 PM, dunbarx at wrote:
> on mouseUp
>    local b
>    answer b + 1
> end mouseUp
> Also works just fine, thank you, and therefore the engine still knows what to 

Right, because even if you put empty into the variable first (as in your 
second message) the act of doing a math calculation forces the variable 
to zero. It happens internally, so you don't see it.

put empty into b
put b = zero -- false
put b+1 -- 1, because empty has converted to zero internally
put b = zero -- false

The point being that until it is used, empty can be either empty or 
zero. Usage determines the value. However, the last line above will put 
"false", because the engine restores the original value if it was specified.

This throws an error:

on mouseUp
   put b = zero -- false
   put b = "" -- false
   put b+1 -- ERROR
end mouseUp

So we can apparently confuse the engine into not knowing what the value 
should be.

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

use-livecode mailing list
use-livecode at
Please visit this url to subscribe, unsubscribe and manage your subscription 


More information about the use-livecode mailing list