4 RTRIM$

This routine trims whitespace (spaces, tabs, carriage returns and line-feeds) from the end (right) of a string.

A%=4:CALL&4083,string$

All arguments are passed by reference. You may pass multiple strings at a time. Both movable strings and fixed strings are supported; all other types are ignored.

The following program:

10 str$="  Hello  "
20 A%=4:CALL&4083,str$
30 PRINT "<"+str$+">"

would output:

<  Hello>

BASIC wrapper function

You can wrap up the routine as a standard BASIC function using the following snippet:

DEFFN_RTRIM$(s$)LOCALA%:A%=4:CALL&4083,s$:=s$

You could then invoke it like this:

PRINT "<"+FN_RTRIM$("  Hello  ")+">"

which would output

<  Hello>

See Also