Probably another n00b question, but here goes.
I want to check a field to see if it has a nil value (ie: is blank)
If it’s blank i want to set its associated variable to 1. Otherwise, set the variable to the number of whatever is in the box.
if (FieldA:getText()==nil) then
NumA = 1
else
NumA = (tonumber(FieldA:getText()))
end
However, if I leave the field blank, when I print NumA in terminal, it is nil, not 1.
If I put a value in Field A, it is displayed properly.
How do I get the functionality I’m looking for?
What field are you talking about? Are you using text candy?
In any case a blank fields text is probably not nil but an empty string “” so try to compare with that.
I’m using the beta version of the editField widget. When I printed out the value in terminal, it came up as nil, so I thought that’s what I was supposed to be testing against.
It seems to work now. Thanks.
What field are you talking about? Are you using text candy?
In any case a blank fields text is probably not nil but an empty string “” so try to compare with that.
I’m using the beta version of the editField widget. When I printed out the value in terminal, it came up as nil, so I thought that’s what I was supposed to be testing against.
It seems to work now. Thanks.