Testing for numerics
Jim Ault
JimAultWins at yahoo.com
Mon Oct 9 21:46:38 EDT 2006
On 10/9/06 3:06 PM, "Ken Ray" <kray at sonsothunder.com> wrote:
> You're right, of course - there's no way to just declare a global and then
> later try and tell the difference between it being newly declared and it
> having had "empty" put into it.
Ken,
I beg to differ, but perhaps I don't know enough about globals in Rev
Globals are in the Rev space, owned by Rev, and will persist even if all
stacks are closed and removed from memory... however
global gVar2
on mouseUp
breakpoint
--gVar2 appears in Variable Watcher, but not in (the globals)
answer "gVar2" is in the globals --FALSE, since it is unused
put 2 into gVar2
answer "gVar2" is in the globals --TRUE, until Rev quits
--it now appears in Variable Watcher listing = 2
end mouseUp
--it now appears in Variable Watcher listing = 2
--along with the environmental globals
Thus you would not have to use "NULL", just the line
if "gVar2" is not in the globals then ...it is less that NULL
--we are testing the string "gVar2", not the value
Note that Variable Watcher will show the globals & values if no handler is
running (except global arrays. they will appear blank, but retain their
value, which can be seen the next time you drop into the debugger)
Script locals / handler locals are purged by the stack / handler.
So... when is a global less than null and not empty? When it is declared
but not used.
PS. Environmental globals have to be declared to be used, as well.
Hope this is correct.
Jim Ault
Las Vegas
More information about the use-livecode
mailing list