Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete leading space on string

Status
Not open for further replies.

flea333

Technical User
Sep 4, 2003
47
US
What is an easy way to get rid of a leading space on a randomly size string?
 
Here's a function from my site that I had written a while back that should do the trick for you:

func StripSpaces : string
param string targetline
integer str_length

strlen targetline str_length ;Get length of string

while str_length > 0 ;While the string has at least one character in it...
if rstrcmp targetline " " 1 ;Compare the first character in the string to a space
strdelete targetline 0 1 ;If the first character is a space, delete it from the string
else
exitwhile ;Else exit the while loop
endif
endwhile

return targetline ;Return modified string
endfunc

aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top