setProp and Lock messages

Pete pete at mollysrevenge.com
Mon Dec 5 11:30:34 CST 2011


Hi Richard,
You're right the reference manual does say that.  And on the very next
page, it says:

"If you use the set command within a setprop handler to set the custom
property for the current object, no setProp trigger is sent to the target
object. (This is to avoid runaway recursion, where the setprop handler
triggers itself)".

Your example and mine appear to contradict each other so I guess there must
be two different circumstances described by these two references.


On Sun, Dec 4, 2011 at 12:10 PM, Richard Gaskin
<ambassador at fourthworld.com>wrote:

> Pete wrote:
>
>  I think the reference to the documentation not being believable alluded to
>> the LC documentation not the datagrid documentation.  The LC Reference
>> Manual and the dictionary are old and definitely contain inaccuracies.  On
>> the topic of setprop and recursion, for example, the reference manual
>> clearly states that you don't need to user lock messages to prevent
>> recursion but, as several people have mentioned in this thread, you do.
>>
>
> Here's what the docs say with regard to recursion for setProp:
>
>   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 result:
>
>    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.
>    end myCustomProperty
>
>   To avoid this problem, set the lockMessages property to true
>   before setting the custom property.
>
>
> I believe that's correct, and have not experienced any bugs which differ
> from that description.
>
> Has anyone here found a recipe for a behavior which contradicts that
> description?
>
>
> --
>  Richard Gaskin
>  Fourth World
>  LiveCode training and consulting: http://www.fourthworld.com
>  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
>  LiveCode Journal blog: http://LiveCodejournal.com/**blog.irv<http://LiveCodejournal.com/blog.irv>
>
> ______________________________**_________________
> 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<http://lists.runrev.com/mailman/listinfo/use-livecode>
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>


More information about the use-livecode mailing list