Call a function on another card

Peter Bogdanoff bogdanoff at me.com
Thu Feb 23 19:14:05 EST 2017


Thanks Bob, I’ll look at this more closely.

One benefit of using custom properties rather than local variables is that I’ve seen that local variables are sometimes emptied on some script errors when working on a script. Then I have to quit and reload the stack.

Peter


On Feb 23, 2017, at 3:17 PM, Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:

> I did a quick little test. The card's script local variables are not accessible from the behavior script. 
> 
> At this point you might consider using card properties instead. This is what I have been doing. This way each card can have it's own "variables" in the form of properties. Then you can have a function in each card script that returns the value stored in the property:
> 
> function cardProp pPropName
>   return the pPropName of me
> end cardProp
> 
> Booyah. I use this myself. The nice thing about using properties is that if there is no such property there will not be any error thrown. 
> 
> Bob S
> 
> 
>> On Feb 23, 2017, at 14:56 , Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
>> 
>> I may be mistaken, but I think that script locals are accessible to a behavior script. If so, you could keep the script local variables in the card, and the handlers in a library or backscript. I will set up a test for that. 
>> 
>> Bob S
>> 
>> 
>>> On Feb 23, 2017, at 14:51 , Peter Bogdanoff via use-livecode <use-livecode at lists.runrev.com> wrote:
>>> 
>>> Bob,
>>> 
>>> This is a good question. In my case, each card script has script local variables that are used only for that card.
>>> 
>>> In this unusual case (I’m creating a text search method) I need to access the contents of those variables from another stack.
>>> 
>>> I indeed would like to move common handlers to a stack or library script, but these handlers use many local variables relevant to the individual cards. I have not yet thought of a simple way to use common handlers without a LOT of passing of local variable data.
>> 
>> 
>> _______________________________________________
>> 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





More information about the Use-livecode mailing list