defining and using globals in an application

Jim Ault jimaultwins at yahoo.com
Fri Jul 8 07:45:45 EDT 2011


On Jul 7, 2011, at 9:11 AM, Bob Sneidar wrote:

> I don't think it's a bug IMHO. How can a variable in the same script  
> have 2 scopes? How would the app know which you were talking about  
> when you used it?
>
> Bob
>


I think you should consider the word 'namespace'.  This means objects,  
processes, variables (reserved memory registers) are always created in  
some sort of namespace.

A real world example would be your refrigerator in your kitchen.  All  
of your neighbors have a refrigerator, but the contents of their  
freezer is independent of your freezer.  Their refrigerator is in a  
different namespace.

For an app running on Windows, Mac, Linux, etc.  there are always  
system variables that are accessible by those processes, and those  
processes make some of their variables available to others.

Your question ' How would the app know which you were talking about  
when you used it?'
  is that the app always knows the full path namespace of objects,  
variables, process threads, sockets, ... just as you would  
automatically know if you were opening your own refrigerator or your  
neighbor's.   Variables cannot float around in computer memory on  
their own.  Operating systems that allow that would crash constantly.

So, the fact that you get to refer to a variable by is 'short name' in  
a script does not mean there isn't a namespace definition in play.  If  
you observe carefully in the Variable Watcher window, you can see more  
that one entry in the list for a particular variable name, and this  
means multiple declarations are active, and you should correct your  
scripting to 'make this go away'

The result of the previous condition will let Livecode resolve the  
ambiguity of which variable to manipulate.

Hope this helps, and I welcome comments on how my discussion is  
inaccurate or misinformed.



Jim Ault
Las Vegas






More information about the use-livecode mailing list