Script Only Stack Behaviors and Nesting

Mike Bonner bonnmike at gmail.com
Mon Jul 2 21:04:02 EDT 2018


Curious if this would be useful.  It occurred to me that one could use
getters and setters in the behavior if one wanted a "central" location for
data for objects using that behavior.

Not as easy as just using an actual property set, but might end up being
faster?

To test I put the following into a button to use as a behavior..
local sOhBehaveLocalA

on mouseup
   -- sets a value in the local of the behavior object
   -- based on the long id of the object using the behavior
   set the setter[(the long id of me)] of (the behavior of me) to
random(4000)

   -- grabs the whole array from the behavior object
   put the getter of (the behavior of me) into tArray

   -- shows the value assigned to the array entry for the
   -- object using the behavior keyed by long id
   put tArray[the long id of me] & cr

   --cycles through all keys in the array returned by getter
   -- and shows values for all objects tracked by the getter/setter in the
behavior object
   put the keys of tArray into tKeys
   repeat for each line tLine in tKeys
      put tLine & ":" & tArray[tLine] & cr after msg
   end repeat

end mouseup

Then assigned the behavior to several buttons and it works well enough.
LIke I said, i'm not sure there is actually a point to this since there are
so many other ways the same objective could be reached, but thought I'd
toss it out there.  (sorry for the ugly code and silly example) I think I
read somewhere that setting a variable is faster than setting a property,
but.. /shrug

On Mon, Jul 2, 2018 at 6:27 PM Mark Wieder via use-livecode <
use-livecode at lists.runrev.com> wrote:

> On 07/02/2018 04:16 PM, Bob Sneidar via use-livecode wrote:
> > oic. Well getting the stacks custom property and referencing that is
> working for me. It's curious then if you can use the sLocal of this me,
> could you also use the sLocal of button x or stack y?? That would be very
> cool! That would mean you could get and set the script locals of another
> object.
>
> Ick
>
> --
>   Mark Wieder
>   ahsoftware at gmail.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