Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Removing repetitive spaces from strings
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00032009
Message ID:
00032319
Views:
40
>>>Yes, I know, but I was hoping that there was a function to do this already. Thanks anyway for your time and code.
>>Take a look at the STRTRAN() function
>
>That is eventually what I ended up using. Unfortunately, I had to call STRTRAN() in a loop to remove all repetitve spaces. If anyone knows of a Windows API call to do this, I would be very interested to hear about it.
>
>By the way, here is the code that I used:
>
>LPARAMETERS tcString
>LOCAL lcRetVal
>LOCAL lnNewLen, lnOldLen
>
>lcRetVal = ALLTRIM(tcString) && Remove leading a trailing spaces
>lnNewLen = LEN(lcRetVal) && Length of string
>lnOldLen = lnNewLen + 1 && Make sure that loop is done at least once
>
>DO WHILE lnNewLen < lnOldLen && While more repetitive spaces exist...
> lnOldLen = lnNewLen && Length before removal of spaces
> lcRetVal = STRTRAN(lcRetVal, SPACE(2), SPACE(1))
> && Remove repetitive spaces
> lnNewLen = LEN(lcRetVal) && Length after removal of spaces
>ENDDO
>
>RETURN lcRetVal
>
>Thanks anyway!
Just out of idle curiosity, why not STRTRAN(lcRetVal,' ','')
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform