Page 1 of 1

checking for empty field

Posted: Sun Feb 10, 2013 9:08 pm
by tyarmsteadBUSuSfT
I'm having a brain fade. I want to Get the info in a field and put it into a variable. Then if that field is blank or empty, use the if option to decide the next course of action. However when I Get the field then put it into a variable or just use the "it" result I have the problem. If the "it" or the variable is empty I can get the If tVariable is Empty then... to work. I've tried If tVariable is "" then, If tVariable is not text then...
Fo illustration purposes I am using tVariable.
Thank you,

Re: checking for empty field

Posted: Sun Feb 10, 2013 10:22 pm
by sturgis
You can check the field directly..
if field "fieldname" is empty then

else

end if

Or skip get and put the contents right into your variable

put field "fieldname" into tVariable
if tVariable is empty then

else

end if


Using get you can

get field "fieldname"
if it is not empty then
put it into tVariable
else
-- it was empty..
end if

Re: checking for empty field

Posted: Sun Feb 10, 2013 11:09 pm
by dunbarx
Hi.

What Sturgis said.

But where are you getting that brain thing? Is it that you do not trust the fact that if nothing is in your variables (whichever they are), then you are not sure that means its value is empty? If so, I sort of get that. Practice for a while and it will go away. Empty means just that, no content, a string of zero length (though not "0" per se).

You can always test, and I think you already did:

if yourVariable = empty then beep 3 --or whatever

This is more useful than you might think. There are many times when a field, say, looks empty, but is not. It might contain return or tab characters, for example.

Your question is very reasonable. Did I mention to practice?.

Craig Newman