Global scope of functions

Robert J. Earp bob.earp at ashford.ca
Thu Jul 14 12:55:38 EDT 2005


Rob,
You're doing the right thing in that it's best to get common functions 
(handlers/script) at the highest level you can, and the stack level is 
OK if you don't intend to ever use those functions in other stacks.  If 
there is that chance, I'd suggest you create a stack just for your 
common functions (call it myCommonFunctions or something), and link it 
on startup of your project stacks like....

on openStack
    start using stack "myCommonFunctions"
end openStack

(this goes into your project stack/s)

.... which puts the stack script in the message path.  If you have a lot 
of functions and wish to group them, say on different cards or different 
buttons in your common functions stack, then just use handlers at the 
stack level to pass the message on to the appropriate place.  I find 
this a nice neat way of keeping track of things without having to scroll 
through long lists of script.

You may wish to close the common functions stack when you close your 
project, although I don;t think this is necessary if you are building a 
standalone.  This is done via...........

on closeStack
    stop using stack "myCommonFunctions"
end closeStack


HTH, Bob....


>Dear Colleagues
>I'm producing a new tool for my research, and I'm trying to do this
>'properly'. In other words, I am trying to cut down the amount of coding
>scattered through the application (buttons, menus etc) and put calls
>to functions or handlers at these locations. I then assemble all the
>functions and handlers in the stack script (app is a 1 card stack).
>
>Is this the logical way forward, or have others found better ways?
>
>-- 
>All best wishes,
>Rob
>

-- 
Robert J. Earp - Ashford Training Technologies*
*18059 21A Avenue, South Surrey, British Columbia, Canada. V3S 9V7
T:(1)604 541 1662 Cel:(1)604 612 6688 F:(1)604 541 1686


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.15/49 - Release Date: 14/07/2005




More information about the use-livecode mailing list