For those of us who are more experienced with the many BASIC languages out there, you may be familiar with the TRIM command.
In short, the TRIM command removes any excess spaces from the beginning and end of a string while leaving the spaces in the middle perfectly intact. Comes in very handy in all sorts of scenarios.
From what I can see, there is no such command in DBpro (please correct me if I'm wrong, though...)
Anyway, in case there isn't such a command, simply add in this function to your code and you will have access to it:
FUNCTION TRIM(InputString$)
RetVal$ = ""
FOR Count = 1 TO LEN(InputString$)
IF MID$(InputString$, Count) <> " "
EXIT
ENDIF
NEXT Count
Temp$ = RIGHT$(InputString$, (LEN(InputString$)-(Count-1)))
FOR Count = LEN(Temp$) TO 1 STEP -1
IF MID$(Temp$, Count) <> " "
EXIT
ENDIF
NEXT Count
Temp2$ = LEFT$(Temp$, Count)
RetVal$ = Temp2$
ENDFUNCTION RetVal$
Here is an example of its use:
CLS
MyVal$ = " Hello world! "
PRINT "(" + TRIM(MyVal$) + ")"
`As you can see, the brackets perfectly surround the inner string!
WAIT KEY
END
FUNCTION TRIM(InputString$)
RetVal$ = ""
FOR Count = 1 TO LEN(InputString$)
IF MID$(InputString$, Count) <> " "
EXIT
ENDIF
NEXT Count
Temp$ = RIGHT$(InputString$, (LEN(InputString$)-(Count-1)))
FOR Count = LEN(Temp$) TO 1 STEP -1
IF MID$(Temp$, Count) <> " "
EXIT
ENDIF
NEXT Count
Temp2$ = LEFT$(Temp$, Count)
RetVal$ = Temp2$
ENDFUNCTION RetVal$
I know it's pretty simple, but it may be just one of those little things that helps someone. If it can help just one person I'll be happy. Just thought I'd share!
Thanks guys!
Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com