>>How can I loop through all the fields (assuming only one record to start, but there could be more eventually) and concatenate all the resulting values into one string?
>
>Jay,
>
>the approach you discuss later on is workable - but if the "more eventually" comes into large table range and/or the table has many fields, the concatenate operation itself (because the string has to be recopied again and again) can become troublesome.
>
>Adding to a file will become faster (because the no string reallocation occurs) or an alternate approach like building line concatenating all fields in one instruction will help. Again, the value here is not saving the loop by replacing it with a makroexpansion, but reducing the number of string movements of growing strings. On multimillion record tables it would be reccomended to add the bracketing scan / endscan and execscript and compile that so that you eliminate the makroexpansion for each record.
>
>The time needed will depend on the string length and the number of operations: if the scan loop takes more than a second (or needs to be performed in a loop as well) take a look at the options described. 10**5 operations are a breeze, around 10**6 you will start to feel the exponetial perf drag.
And we already have a single method which will do it in one step:
_vfp.datatoclip(,,3)
Then it's only a matter of manipulating that one string on the clipboard into a format we want. The fields are separated by tabs, records by CRLF (or was it just CR?). Nice and easy.
There's the trouble with the field names being in the first line, but it takes just two commands to remove it.