Script Only Stack Architecture

Sannyasin Brahmanathaswami brahma at hindu.org
Wed Mar 30 22:14:28 EDT 2016


@ Richard:

I looked at the bug 8993 . The problem is... what does "loaded" actually mean?

After two days of research, study and testing and responses here...
 I *still* could not  figure it out (until now thanks to your tip on stack files)

Indeed a serious confusion/conundrum for a new comer.

Create script-only.livecode stack

script "script-only"
on mouseup
   Put "Hello" into me
end mouseup

Save, open and apply as behavior to field. lock field, click on it.. nothing happens. msg is not sent to the behavior script.

put  this into preopenstack

start using stack  "[path-to]/script-only.livecode"

Now the madness begins: the stack accepts mousedown from *anywhere* on the UI and triggers an error, because "me" is not the field to which the behavior was applied.

 changing the preopenstack handler to

open stack  "[path-to]/script-only.livecode"

does not "load" it as such.. it is open, You can see it if you were to set behaviors it is there in the dropdown menu under the inspector but the field that has it set as a behavior does not trigger the mouseup in the behavior stack script. Baffling for a newbie.

IN the bug Mark Waddington writes: "I'm going to cease thinking of this as an enhancement request, and instead as a bug - the method used currently is too opaque."

opaque is an understatement. Virtually Impenetrable may be better.

Stack files Wow... that works!

So why not just declared this asap  and very, very explicitly in the new documentation, ugly and as verbose as this appears, this is what we need:

---------

"In order to use script only stacks  as behaviors in specific controls, these must be loaded as stack files so that they are placed into the message path along with the scripts of your main stack. In your main stack (or substacks that may use them)   Use the inspector, choose stack files and browse to choose your script on disk.

Unlike button behaviors which are embedded in your stack, you must be sure to include these stacks later when you move, package or distribute your main stack. Also be aware that the main stack cannot track changes to the location of these stack files. If you move them on disk the reference to the stack will fail and you will need to update the stack files and point to the stack in it's new locations.

Also note that it if you use "open" to open your script only stack file... it is still not in the message path and your behaviors will fail, furthermore, if you put "start using stack" (in an open stack, preopenstack  handler) to load your script only stack, it will receive all messages from the stack and not just from the child control to which it is assigned. e.g. if your intent is for the child control(s) to respond to "on mouseup"  this will not work if you do "start using" for your script-only stack."

-----------



More information about the use-livecode mailing list