Does a Control Exist?

dunbarx at aol.com dunbarx at aol.com
Sun Nov 24 12:13:31 EST 2013


I think that a strict constructionist position is best here.


Though it is less of an issue if you:


put fld "foo" into myVar


and there is no fld "foo"


It seems to me very dangerous to try to:


put myVar into fld "foo"


when there is no such field.


This could lead users astray, including the original author.


Craig


P.S. Jacque and many others will know where 'foo" came from. What about "author"?



-----Original Message-----
From: Ray <ray at linkit.com>
To: use-livecode <use-livecode at lists.runrev.com>
Sent: Sun, Nov 24, 2013 11:59 am
Subject: Re: Does a Control Exist?


Yeah, I know there are various ways of checking whether the control 
exists or not before proceeding.  I just wondered whether anybody else 
thought it might be nice not to have to do that since it does halt the 
script if the control doesn't exist.

On 11/24/2013 11:46 AM, Richmond wrote:
> On 24.11.2013 18:31, 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 is...
>>    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?
>>
>> Ray Horsley
>> LinkIt! Software
>>
>
> Well, surely the trick is to do something like this:
>
> if exists(fld "My Field") then
>     put fld "My Field" into myVar
> end if
>
> Easy-Peasy-Lemon-Squeezy!
>
> Richmond.
>
> _______________________________________________
> 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