Retro Rocket OS
BASIC-Powered Operating System
Loading...
Searching...
No Matches
TRIM$ Function
TRIM$(string-expression)

Removes all leading and trailing spaces from the string expression and returns the result.


Examples

PRINT TRIM$(" Hello ")

Produces "Hello".

REM Normalise user input
input$ = " command "
PRINT "["; TRIM$(input$); "]"

Produces [command].


Notes

  • Only space characters (CHR$(32)) are removed; tabs and other whitespace are not affected.
  • If the string has no leading or trailing spaces, it is returned unchanged.
  • For trimming only one side: use LTRIM$ or RTRIM$.

See also: LTRIM$ · RTRIM$ · LEN