forked from Galleondragon/qb64
-
Notifications
You must be signed in to change notification settings - Fork 24
_TRIM$
Cory Smith edited this page Sep 1, 2022
·
4 revisions
The _TRIM$ function removes both leading and trailing space characters from a STRING value.
return$ = _TRIM$(text$)
- Shorthand to using LTRIM$(RTRIM$("text"))
- text$ is the STRING value to trim.
- If text$ contains no leading or trailing space characters, it is returned unchanged.
- Convert fixed length STRING values by using a different return$ variable.
Demonstrating how _TRIM$(text$) can replace LTRIM$(RTRIM$(text$)):
text$ = SPACE$(10) + "some text" + SPACE$(10)
PRINT "[" + text$ + "]"
PRINT "[" + RTRIM$(text$) + "]"
PRINT "[" + LTRIM$(text$) + "]"
PRINT "[" + LTRIM$(RTRIM$(text$)) + "]"
PRINT "[" + _TRIM$(text$) + "]"
[ some text ]
[ some text]
[some text ]
[some text]
[some text]