How/When are behavior references resolved?

Pete pete at mollysrevenge.com
Sat Jul 16 13:37:07 EDT 2011


Thanks Ken, I'm still having issues with this and I suspect it's because of
just when I issue these commands.

Right now, the "start using" command is the preOpenCard handler of the first
card of my main stack.  If I refresh the Application Browser, I see my
library file listed there.  I added the "open invisible" command right after
the "start using" but that still didn't fix the problem.

The only way I can make things work reliably right now is to manually open
my library file before opening my application file, which is OK for now in
my development environment but need to find a better solution somehow.


Pete
Molly's Revenge <http://www.mollysrevenge.com>




On Fri, Jul 15, 2011 at 4:59 PM, Ken Ray <kray at sonsothunder.com> wrote:

>
> On Jul 15, 2011, at 3:29 PM, Pete wrote:
>
> > I'm having a problem with behaviors not being resolved in my application
> > stack.
> >
> > I have two stack files, lets call them library.livecode and
> > application.livecode.  The script of the main stack of library.livecode
> has
> > handlers that I use in application.livecode by issuing a "start using"
> > command.
> >
> > library.livecode also contains a substack named Behaviors whose card has
> a
> > bunch of buttons whose scripts I want to use as behaviors in
> > application.livecode butthe "start using" command doesn't seem to make
> the
> > behaviors available to the controls in application.livecode, by which I
> mean
> > they act like they don't have a behavior defined.
> >
> > I can fix this by setting the stackFiles of the main stack of
> > application.livecode to "Behaviors,<path to library.livecode>".  I have
> to
> > reference the Behaviors substack, not the main stack of library.livecode
> for
> > this to work.
> >
> > I guess I'm wondering if this is the appropriate way to deal with this
> > situation or if there's a cleaner way to do it.
>
> You're right - putting a stack into use doesn't load it into memory (e.g.
> it's not in the mainstacks), so the behaviors go unresolved. Here's two ways
> to do it (other than the one you described):
>
> 1) Open the library invisibly (I do this by trapping "on libraryStack":
>
> on libraryStack
>  if the target is me then
>    open inv stack (the short name of me)
>  end if
> end libraryStack
>
> 2) The "datagrid" trick - if you use "there is a stack" then it loads a
> stack into memory but doesn't actually open it:
>
> get (there is a stack <pathToStack>)
>
>
>
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
>
> _______________________________________________
> 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