Script Only Stack Behaviors and Nesting
bobsneidar at iotecdigital.com
Mon Jul 2 19:16:14 EDT 2018
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.
> On Jul 2, 2018, at 12:33 , J. Landman Gay via use-livecode <use-livecode at lists.runrev.com> wrote:
> Actually, do you mean you want to set the script locals for the behavior object itself? You can do that, but it will only apply to that particular control. The magic word is "this me" : "set the sLocal of this me to xxx".
> If you want the script locals of the behavior object to be shared for every other object that uses the behavior, you need global variables. Behaviors act like they are the actual script of an object. Setting a script local for button 1 wouldn't share that value with button 2.
> On 7/2/18 2:17 PM, J. Landman Gay via use-livecode wrote:
>> They do retain independent values, one set of script locals for each instance. For example, if you have two buttons that use the same behavior, button 1 will retain its script local values and button 2 will retain its own (different) set of values.
>> On 7/2/18 1:42 PM, Bob Sneidar via use-livecode wrote:
>>> Okay, so apparently I cannot use script local variables in a behavior. Setting the variables in a handler in a behavior script does not retain the values when that handler exits, like they do in a normal object script. Should they?
>>> The workaround for me is to simply get the custom property of each stack (an array in each stack containing all the values I need) and then reference the array values directly instead of trying to set script local values. The downside to this is I have to get the array in every handler in the behavior script. Not a big deal, but I was trying to be efficient by only having to initialize the values once upon every openStack.
>>> Bob S
>>>> On Jul 2, 2018, at 10:05 , Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>> Hi all. I nailed this down, and it is indeed as someone surmised, that even though the script editor variable watcher indicated that script local variables had the correct values, it was showing me the BEHAVIOR's script local variable values, and NOT those for the STACK, which were in fact still empty (not initialized).
>>>> This is likely going to bite others in the butt in the future, who use the same script local variables in their behaviors as they do in their parent script. Who knows, maybe I'm going to be the only one in the history of LC to try this, but I just thought I'd toss that out there, in case anyone else gets obscure bugs where a statement ought to work and doesn't.
>>>> Bob S
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode