Does a Control Exist?
J. Landman Gay
jacque at hyperactivesw.com
Sun Nov 24 20:08:15 CET 2013
On 11/24/13 10:31 AM, Ray wrote:
> After loosely following the item delimiter thread last week a similar
> idea came to me today which might be an interesting discussion.
> It's often time consuming to type spell out...
> if there is a field "My Field" then put field "My Field" into myVar
> If I don't first check to see if the control exists [and it doesn't] I
> get an error and the script stops execution.
> I don't have to do this with a custom property. That is if the script
> put the NewProperty of this card into myVar
> and said property doesn't exist, I simply end up with nothing in myVar,
> but it doesn't cause an error and the script continues.
> Does anybody think it would be worth it to have a way to stop errors
> from being produced when referring to non-existent controls?
I think it would be dangerous, there would be too many other script
complications if the engine worked that way. But you can do this on your
own without a change to the engine. Instead of directly putting text
into the field (or manipulating any other control,) create a setProp
handler that does it instead. Then the setProp handler can check the
existence and just exit without taking any action if the object doesn't
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode