Good Evening Tracy:
You second example is basicaly what I am doing now. My code:
lparameter lcString_to_strip
local lbGot_space, lcNew_string, i
lbGot_space = .f.
lcNew_string = ""
lcString_to_strip = ltrim(lcString_to_strip)
for i = 1 to len(lcString_to_strip)
do case
case not lbGot_space and substr(lcString_to_strip, i, 1) = space(1)
lcNew_string = lcNew_string + space(1)
lbGot_space = .t.
case lbGot_space and substr(lcString_to_strip, i, 1) = space(1)
loop
otherwise
lbGot_space = .f.
lcNew_string = lcNew_string + substr(lcString_to_strip, i, 1)
endcase
endfor
return rtrim(lcNew_string)
But I really don't want to include foxtools...so I guess I will stick with what
I have. Although your second example is better coded!
Thanks for the examples!
Regards,
Jack
________________________________________
From: [email protected] [[email protected]] On Behalf Of
Tracy Pearson [[email protected]]
Sent: Tuesday, January 25, 2011 4:43 PM
To: [email protected]
Subject: RE: Multiple Space Replacement
Jack Skelley wrote on 2011-01-25:
> Tracy: Thanks. I realize that but don't want to include foxtools in the
> system... Regards,
>
> Jack
>
Jack,
I don't know of a sure way to get all spaces on a single command line.
Though this works
cText = "Spaces Test"
DO WHILE AT(SPACE(2), cText) > 0
cText = STRTRAN(cText, SPACE(2), SPACE(1))
ENDDO
?LEN(cText)
This would probably be faster with large amounts of text
cText = "Spaces Test"
cLast = "-"
cCurrent = ""
cNew = ""
FOR nSpaceLoop = 1 TO LEN(cText)
cCurrent = SUBSTR(cText, nSpaceLoop, 1)
IF cCurrent = SPACE(1) AND cLast = SPACE(1)
ELSE
cNew = cNew + cCurrent
cLast = cCurrent
ENDIF
NEXT
?LEN(cNew)
Yet, the REDUCE function is C and faster yet.
YMMV
Tracy Pearson
PowerChurch Software
<a href="http://devils.nhl.com/"><IMG
SRC=http://c1.newjerseydevils.com/sig/[email protected]
border="0" usemap="#Map"></a>
<map name="Map">
<area shape="rect" coords="4,67,203,85"
href="http://devils.nhl.com/club/page.htm?id=65573" target="_blank">
<area shape="rect" coords="269,67,346,87" href="http://www.prucenter.com/"
target="_blank">
<area shape="rect" coords="243,43,264,62"
href="http://www.youtube.com/prudentialcenter" target="_blank">
<area shape="rect" coords="223,43,244,62" href="http://twitter.com/nhldevils"
target="_blank"><area shape="rect" coords="203,43,224,62"
href="http://www.facebook.com/NewJerseyDevils?ref=ts" target="_blank">
</map>
</A>
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/0b957900b2b8194d998a441195b6603839820f0...@drdsrv03.drdad.thenewarkarena.com
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.