Claude,
>
Thanks for the reply. I missunderstood your original posting and thought you were suggesting I create a variable to do all the replaces at once. I do have several questions on your code.
>
>1. Why do you use EVALUATE(taField) instead of macro substition of the vairable, i.e. is it faster?Yes.
>
>2. Why call a function instead of using inline code?I find it more readable and easier to code that way. Theoretically, inline code would probably be faster but I doubt the difference would be significant.
>
>
>>Claude,
>>
>>OK, I hadn't tested what I suggested and it had some problems. Here is some code I have tested that works. I'm not sure what characters you are eliminating so I just picked 2 at random and ran the following test program with a field in the table that has them plus a number of embedded spaces.
>>
>>#DEFINE BADCHARS CHR(128)+CHR(129)
>>#DEFINE ONE SPACE(1)
>>#DEFINE TWO SPACE(2)
>>
>>LOCAL lnFldCnt, lnPtr
>>LOCAL ARRAY laFields[1]
>>SET STEP ON
>>IF USED('Tran0')
>> SELECT Tran0
>>ELSE
>> USE Tran0
>>ENDIF
>>
>>lnFldCnt = AFIELDS(laFields)
>>
>>SCAN
>>
>> FOR lnPtr = 1 TO lnFldCnt
>> IF laFields[lnPtr,2] = 'C' OR ;
>> laFields[lnPtr,2] = 'M'
>> = Cleanup(laFields[lnPtr,1])
>> ENDIF
>> ENDFOR
>>
>>ENDSCAN
>>
>>FUNCTION Cleanup
>>LPARAMETERS taField
>>LOCAL lcString1, lcString2
>>
>>m.lcString1 = EVALUATE(taField)
>>
>>m.lcString2 = CHRTRAN(m.lcString1,BADCHARS,'')
>>
>>DO WHILE TWO $ m.lcString2
>> m.lcString2 = STRTRAN(m.lcString2,TWO,ONE)
>>ENDDO
>>
>>IF LEN(ALLTRIM(m.lcString2)) < LEN(ALLTRIM(m.lcString1))
>> REPLACE (taField) WITH m.lcString2
>>ENDIF
>>RETURN
>>
>>Hope this is a little more helpful!
Jim