Code archives/Miscellaneous/new trim$ function

This code has been declared by its author to be Public Domain code.

Download source code

new trim$ function by dan_upright2001
trim$ does not work as it says in the docs, it not only removes spaces, but any unprintable characters too, new_trim$ only removes spaces
Function new_trim$(t$)

	If t$ = " " Then t$ = ""
	If Len(t$) > 0
		Repeat
			a = a + 1
			c$ = Mid$(t$,a,1)
		Until (c$ <> " ") Or (a = Len(t$))
		b = Len(t$) + 1
		Repeat
			b = b - 1
			c$ = Mid$(t$,b,1)
		Until (c$ <> " ") Or (b = 1)
		
		Return Mid$(t$,a,(b - (a - 1)))
	Else
		Return ""
	EndIf

End Function

Comments

None.

Code Archives Forum