setptop handler and recursion limit?
mark at livecode.com
Fri Jun 24 13:19:34 CEST 2016
On 2016-06-24 13:12, Klaus major-k wrote:
> I have a handler in the stack script like this:
> setprop whatever tValue
> set the whatever of the target to tValue
> answer "The property whatever has been modified for" && the target
> end x_value
> And on a card I have a button:
> set the whatever of this cd to 22
> Now in LC 8.01 I get "Recursion limit" error!?
> I thought that this would not happen for setprop handlers?
> See my setprop script, I actually need to "pass" the message
> to really set that value. Know what I mean?
I think the docs cover this:
Caution! If a setProp handler in one object's script sets the custom
property for a different object, and the first object is in the second
object's message path, a runaway recursion will result. For example, if
the following handler is in a card script, and you set the
"myCustomProperty" of a button on the card, runaway recursion will
setProp myCustomProperty newValue
set the myCustomProperty of the target to newValue + 1
-- Because the target is the button, and this handler is in
-- the card, the above statement sends another setProp trigger
-- to the button.
To avoid this problem, set the lockMessages property to true before
setting the custom property.
You have a setProp handler in the stack, but are setting it on the card
- as the target of the object is not the same as object containing the
setProp handler then you need to use 'lock messages' around the set in
the setProp handler.
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps
More information about the use-livecode