>>>>>Before I wrote my code, I test reduce(). It didn`t strip CHR(13), only CHR(10)
>>>>
>>>>Like I said, Vbscript.RegExp covers the issue just fine.
>>>
>>>How about another, pure VFP solution, in just as many lines of code?
>>>
>>>* Converts all carriage returns and line feeds to spaces
>>>lcString = CHRTRAN(lcString, CHR(13)+CHR(10),SPACE(1))
>>>* Reduce all strings of spaces to a single space
>>>DO WHILE SPACE(2)$lcString]
>>> lcString = STRTRAN(lcString, SPACE(2), SPACE(1))
>>>ENDDO
>>>
>>
>>More costly - can't put that in except through a UDF - all I do is create an object and use it.
>
>Depends on the string eh? For short strings like a SQL statement, this will probably be faster than your COM object creation. CHRTRAN has been shown to cause performance problems in extremely large strings, but STRTRAN is devilishly fast. Also, no external dependencies to worry about.
Yeah, but you missed occurances of CR sans LF, LF sans CR, multiple LFs, FFs, tab translation...you need something on the order of a more sophisiticated tool than just simple STRTRAN()/CHRTRAN() and a little looping.
Understood that it isn't all VFP, but then, I like using more than one tool at a time, and since I leverage so much from WSH and get the COM object 'for free' by insisting on WSH, I'd be crazy not to do it my way. YMMV, of course.
What I really like is that I solve the problem the same way in VB, VFP, Jscript - anywhere I want to leverage it, it does the job.