>>I found a problem. Somehow the lcPattern variable definition was changed. Instead of
>>
lcPattern=left(tcDBFName,lnPos+1)+'???'+substr(tcDBFName,lnPos+4)
>>it was something different. Therefore the program just didn't do anything...
>>
>>I'm testing the speed difference right now.
>>
>>>>Should I revert the code back to the original cursor idea?
>>>
>>>As far as effeicent goes, I'd bet that the cursor idea is faster anyways, so yes. You could easily test it out.
>
>If speed is the issue, and you're replacing a character by character (not string by string), you may check using ChrTran() instead of StrTran() - it should be faster.
>
>Another handy trick, assuming you're replacing two characters with three question marks, instead of
>
lcPattern=left(tcDBFName,lnPos+1)+'???'+substr(tcDBFName,lnPos+4)
>you could use
>
lcPattern=Stuff(tcDBFName,lnPos+2, 2, '???')
>A single function should be faster than two functions plus two string concatenateions. Besides, I always thought that all the string chopping functions (left, right, substr()) are internally done as Stuff() with special parameters.
Thanks for the insight, Dragan. This is a minor enhancement, but I'll put it also. The problem is that I have text files (produced as a result of copy to command). I need these files to not have double quotes as Field separators, e.g. remove all " from these text files. These files could be huge (up to 30MB). Therefore I'm searching for the most efficient way to achieve my goal.
If it's not broken, fix it until it is.
My Blog