Testing for numerics

Jim Ault JimAultWins at yahoo.com
Fri Oct 6 02:22:06 EDT 2006

On 10/5/06 4:53 PM, "Robert Sneidar" <bobs at twft.com> wrote:
> The benefit would be that I could use the state of the global to
> determine if this was the first time it had been initialized and run
> some setup code. The natural state of certain globals is empty, so I
> couldn't simply test for that. If I were coding from scratch I would
> just work around this, but I am porting business logic from another
> dev environment. They use this extensively.

Try using  >  the globalNames

---------script lines --------------
global gGlobalNameArr

on preopenStack
  put the globalNames into listToRegister
  repeat for each item GBLNM in listToRegister
    get  GBLNM&"_"
    if it is "gGlobalNameArr_" then next repeat
    do "global "& GBLNM  --need this to declare for this handler
    if char 1 to 4 of it is "gRev" then next repeat
    if char 1 of it is "$" then next repeat

    do "put "& GBLNM &" into gGlobalNameArr["&it&"]"
  end repeat

end preopenstack

--the gGlobalNameArr  array is a global
--now the keys of the arr = the list of (global names&"_")
--the values = the startup value of the globals, except gGlobalNameArr
--whenever you process a global, compare to gGlobalNameArr[GBLNM&"_"]
--the reason for the "_" is that the 'do' cmd will interpret the global
rather than use its name in the index of the array.
--because gGlobalNameArr is declared in the same script container, it does
not have to be 

May not be what you need, but thought it might help.

Jim Ault
Las Vegas

> On Oct 5, 2006, at 11:20 AM, J. Landman Gay wrote:
>> On the other hand, just declaring a global automatically
>> initializes it to empty, so maybe that's enough for the original
>> poster. I don't see too much difference between empty and NULL;
>> there's a slight difference but probably not one that would matter
>> too much in most cases.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

More information about the Use-livecode mailing list