Would be nice to re-test and especially Gregory's idea. I do believe that the performance should have been improved if you would not use string concatenation.
>Thanks Naomi - the solution I am using appears adequate for the file size I am working with.
>
>>Did you try fput solution too ?
>>
>>Also, remove lcLine at all from your strtofile test (write directly without lcLine variable).
>>
>>>Sergey, I have done some tests. Your suggestion is much slower (17.2 sec) compared to building a string (0.75 sec) or using TEXTMERGE (0.8 sec). It would seem that for the file size I am using that building the string is a good option.
>>>
>>>UPDATE: I am using 10,000 records and combining 3 fields.
>>>
>>>
>>>>It has been proven that writing to a file line by line could be faster than building string in a memory.
>>>>I would try
>>>>
>>>>lcFileName = "..."
>>>>ERASE(lcFileName)
>>>>SCAN
>>>>
>>>>lcLine = myTable.Field1 + CHR(9) + myTable.Field2 + CHR(9) + CHR(13)
>>>>
>>>>STRTOFILE(lcLine , lcFileName, .T.)
>>>>
>>>>ENDSCAN
>>>>cMyString = FILETOSTR(lcFileName)
>>>>
>>>>
>>>>>I need to add extra formatting text between fields and dependent on field contents. So simple COPY will not work. Do you think using SET TEXTMERGE TO VARIABLE will be faster?
>>>>>
If it's not broken, fix it until it is.
My Blog