Avoiding recursion with a setProp handler
depstein at att.net
depstein at att.net
Mon Aug 23 18:01:40 EDT 2004
Thanks for the help. Klaus Major's "pass" command does the job (but it has to be "pass <theCustomPropertyName>", not "pass setProp").
Further experimentation suggests that the MC Help file's stipulation that "when you set an object's property from within a setprop handler, setprop messages are not sent" applies ONLY if the setProp handler is in that object's own script. If (as I tried to do) you set a property from within a setProp handler in the script of a stackInUse, another setProp message DOES get sent, with recursion problems. So the "validation" use of setProp suggested in the Help stack (i.e., a "setProp percent" handler receives as a parameter the value that the property was set to, and then checks and possibly modifies that value) cannot be used "globally"; it can only be used for the object in whose script that setProp handler appears.
David Epstein
Klaus major wrote:
> Hi David,
>
> > MC 2.5's help stack says that "when you set an object's property from
> > within a setprop handler, setprop messages are not sent." Is this
> > true?
> >
> > Here's my handler:
> >
> > setProp beenChanged whether
> > put the short date into fld 3
> ###set the beenChanged of this stack to whether -- (without this,
> the setProp handler intercepts the calling command, and the property is
> not set)
> pass setprop ## ;-)
> > end setProp
>
> > When some other handler commands "set the beenChanged of this stack to
> > true", my setProp handler gets called. But when I watch the message
> > watcher, it appears that the second line of my setProp handler is
> > recursively calling the setProp handler, and I get a "recursion limit
> > reached" error.
> >
> > I realize that I could easily avoid resorting to a setProp handler at
> > all, but I was tempted by the ease with which I thought it would allow
> > me to add some behavior I had not thought of when I first wrote a lot
> > of handlers that "set the beenChanged of this stack." Having come
> > this far, I would like to understand how to use setProp properly.
>
> See above, simply "pass"ing the "setprop" will finally SET THIS PROP :-)
>
> Hope this helps.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.runrev.com/pipermail/metacard/attachments/20040823/a628d3bd/attachment.htm
More information about the metacard
mailing list