How/When are behavior references resolved?

Phil Davis revdev at pdslabs.net
Sat Jul 16 00:39:52 EDT 2011


On 7/15/11 7:07 PM, dunbarx at aol.com wrote:
> I believe putting a stack into use will only place the stack script in the hierarchy. Objects, like buttons, will not be "seen".
>
>
> Craig Newman

Yet after they are in use, the objects they contain (images at least) can be 
successfully referenced as button icons in other stacks that are open.

Phil Davis

>
>
>
>
> -----Original Message-----
> From: Ken Ray<kray at sonsothunder.com>
> To: How to use LiveCode<use-livecode at lists.runrev.com>
> Sent: Fri, Jul 15, 2011 4:02 pm
> Subject: Re: How/When are behavior references resolved?
>
>
>
> 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
>
>
>
> _______________________________________________
> 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
>

-- 
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net





More information about the use-livecode mailing list