insert script

Ken Ray kray at sonsothunder.com
Mon Sep 6 20:06:38 EDT 2004


On 9/6/04 5:16 PM, "Hershel Fisch" <hershrev at realtorsgroup.us> wrote:

> Hi all ,
> I'm trying to figure out how the insert script works.
> I have a "script Lib." stack containing only custom handlers and
> functions
> I have a sub stack "myStack" in an openStack message I  put in "insert
> script from stack "script Lib" into back"
> Now when I open the sub stack "mySTack" the on openStack message
> triggers the handler from the script lib. even its into back and I have
> an on openStack in the main stack.  Also when open another sub stack
> with no insert script in it , it triggers that same script as said
> above , wondering , what is the proper understanding of the "insert
> script" .

The use of "insert script" is much like the use of libraries - you place an
entire script in the message passing hierarchy, but *after* the "normal"
stacks receive the message. This allows you to trap messages that other
object have not trapped (if you insert into the back - a "backScript"), or
to trap messages before they hit their intended target (if you insert into
the front - a "frontScript"). This applies to all open stacks and substacks
- backscripts are "behind" every stack, and frontScripts are "in front of"
every stack. 

The reason you're getting what you're getting is that when a stack opens, a
number of messages are triggered (openCard, preOpenCard, openStack,
preOpenStack, etc.), and so if the stack that opens doesn't trap all of
these (and most don't), they will make their way "up" (it's how I visualize
it) the message passing hierarchy and eventually hit the backscript which
will get it and activate it. In your case, it's the openStack message.

Personally, I would put the common handlers and functions into another
object and insert *its* script into the back. I commonly do this with a
button called "BS" (for backscript) or "FS" (for frontscript) as in:

  insert the script of btn "BS" into back

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list