B+: Check for nothing but spaces.. How?
Blitz3D Forums/Blitz3D Beginners Area/B+: Check for nothing but spaces.. How?
| ||
Hey, I need to do a check on a TextField, to see if something was typed there or not. My program will not allow to use the TextField, if nothing visible is typed. That could be nothing typed at all, or a bunch of spaces.. I can't thing of a way to do this, other than this clumsy way: Function CheckFor50spaces() If TextFieldText$(SiteNameField)=("") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return If TextFieldText$(SiteNameField)=(" ") Then Notify "You MUST give it a name!" : NoName=True : Return End Function So far, I check up to 50 spaces. But if there are 51 spaces in the TextField, it will be allowed, and I don't want that!! Is there a way to check a TextField for nothing, OR ANY amount of spaces..? |
| ||
Isn't that what you want to do?Function CheckForspaces() txt$=TextFieldText$(SiteNameField) ln% = Len(txt) For i = 1 To ln If Mid(txt, i, 1) <> " " Then NoName = False Return EndIf Next Notify "You MUST give it a name!" NoName=True End Function (I have supposed NoName is a global variable.) Or even simpler: Function CheckForspaces() txt$=TextFieldText$(SiteNameField) NoName = (Trim(txt) = "") If NoName Then Notify "You MUST give it a name!" End Function |
| ||
Some example code:a$=" " b$=" asd " If Trim$(a$)="" Then Print "a$ => Only spaces!" If Trim$(b$)="" Then Print "b$ => Only spaces!" EDIT: Ah, I wrote this when Koriolis updated his post :) |
| ||
The magic command Trim..!! Right. Thanks a lot guys!! :) |