How to test if a field does not contain anything else than returns or tab ?

Andre.Bisseret Andre.Bisseret at inria.fr
Tue Feb 3 10:46:14 EST 2009


Le 3 févr. 09 à 15:22, Klaus Major a écrit :

> Bonjour Andre,
>
>> Bonjour,
>>
>> I need to test if a given list field in a stack contains some  
>> values or if it is empty.
>> Well, by "empty" I mean that the field contains not any word or  
>> number. But it happens that it may include carriage returns and/or  
>> tabs.
>> In such cases :
>> field "thisField" is empty
>> return false.
>>
>> If there were only carriage returns, I could test if each line of  
>> the field is empty;
>> indeed :
>> line x of fld "thisField" is empty
>> returns true if the only character in the line is cr
>> but returns false if there is at least one tab in the line.
>>
>> I just tried :
>> if last char of fld "thisField" is empty  ;-))
>>
>> that seems working well ! but a bit strange and might be not  
>> reliable ?
>>
>> Is there a better trick ?
>
> I would go like this:
> ....
> put fld "Your field here" into Field_content
> replace CR with "" in Field_content
> replace TAB with "" in Field_content
> ## replace anything else that might be necessary
>
> if Field_content = empty then
> ## do your stuff...
> end if
> ....
>
> Hope that helps.

Ouuups, of course, your are right
I feel a bit ridiculous ;-)

Danke sehr Klaus,

André





More information about the use-livecode mailing list