Page 1 of 1

How to determine if a field is filled or not

Posted: Sun Dec 14, 2014 10:28 pm
by Rob van der Sloot
I am retrieving data from a database into LC fields
In one field there is not always a value, so that field remains empty. The database does that perfect.
How can I determine if this field has been filled with a string or has remained empty?
Coming from the Filemaker environment, where it is a simple statement like "If field is empty then....",
but this seems to be totally different in LC, and I can't find the solution.

Please help, should be simple

Thanks

Rob

Re: How to determine if a field is filled or not

Posted: Sun Dec 14, 2014 10:48 pm
by Dixie
In a button, say...

Code: Select all

on mouseUp
   if fld 1 is empty then beep
end mouseUp
If you are putting stuff into flds from a database call, then there might be some invisibles inserted, cr's, spaces... so it might help you to make sure the fields are empty before you make the call to your database... with something as simplle as...

Code: Select all

   repeat with count = 1 to the number of flds
      put empty into fld count
   end repeat

Re: How to determine if a field is filled or not

Posted: Mon Dec 15, 2014 6:44 pm
by jacque
When I want to see if a field has no text, I sometimes use:

Code: Select all

if the number of words in fld x = 0 then
This ignores spaces, returns, and other invisibles. You could use that as a check to see if you need to put empty into the field, or just to ignore the field entirely.

Re: How to determine if a field is filled or not

Posted: Mon Dec 15, 2014 6:48 pm
by Dixie
Jacque...

that's lovely... I would not have thought of that ! :D :D

Re: How to determine if a field is filled or not

Posted: Mon Dec 15, 2014 7:57 pm
by jacque
Thanks Dixie. I should probably warn that doesn't always work though, you need to know your data. Low-ascii characters like the ones that put small boxes into a field will count as a "word". But if you're pretty sure the data contains only typeable characters then it does well.