How to determine if a field is filled or not

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, asayd

Post Reply
Rob van der Sloot
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 49
Joined: Sat Apr 17, 2010 9:21 am

How to determine if a field is filled or not

Post by Rob van der Sloot » Sun Dec 14, 2014 10:28 pm

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

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

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

Post by Dixie » Sun Dec 14, 2014 10:48 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3911
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Mon Dec 15, 2014 6:44 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

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

Post by Dixie » Mon Dec 15, 2014 6:48 pm

Jacque...

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3911
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Mon Dec 15, 2014 7:57 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “LiveCode University”