defining and using globals in an application

Slava Paperno slava at lexiconbridge.com
Wed Jul 6 23:06:48 EDT 2011


Mark,

When I define a global in the main stack, it is available to all its
substacks. Are you sure this is not the case in your application?

You may have already seen this in User Guide:

2.2.4 Main Stacks and Substacks
The first stack created in a stack file is called the mainstack. Any other
stacks created in the same
stack file are called substacks of the mainstack.
The mainstack is part of the object hierarchy of all other stacks in the
same stack file. In other
words (for the purposes of inherited properties and shared behaviors), the
mainstack contains its
substacks.

5.5.4 Global Variables
A global variable can be used in any handler, anywhere in the application.
Unlike a local
variable, a global variable retains its value even after the handler that
created it finishes
executing. Unlike a script local variable, a global variable can be used by
any handler in
any object's script.
The same global variable can be used by any stack during a session. You can
declare a
global variable in one stack, and use it in others.


Slava

> -----Original Message-----
> From: use-livecode-bounces at lists.runrev.com [mailto:use-livecode-
> bounces at lists.runrev.com] On Behalf Of Mark Stuart
> Sent: Wednesday, July 06, 2011 10:56 PM
> To: use-livecode at lists.runrev.com
> Subject: defining and using globals in an application
> 
> Hi all,
> 
> To me, once globals are defined and put with a value, their value
> should be
> available from any stack within the application.
> 
> So far, so good.
> 
> But the problem arises where, within other stacks script, if you don't
> define the required global again, the desired value is not there.
> 
> The result is the name of the global in the stack where that global was
> first defined.
> 
> Not good.
> 
> 
> 
> So why aren't the values of global's, global to the application?
> 
> In other software development languages, this IS the case.
> 
> Wouldn't you want the same in LC? I would.
> 
> 
> 
> Why isn't this the case in LC?
> 
> 
> 
> Regards,
> 
> Mark Stuart
> 
> _______________________________________________
> 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