>I wrote a long program which is an automated process and which uses FPUTS() to write the data to a text file. Everything is looking good in the data before using FPUTS. The problem I now have is that the last record in the table ends up as the first record, the second record, and so on that appears in the text file. However, while I am in DEBUG mode stepping through the program, I see that the record pointer is actually sitting on the first record; this is totally odd, because the data which writes to the text file first is the 21st record, not the 1st. Why is this?
>
>I'l put in some of the code:
>
>
>SELECT tmpData
>SET ORDER TO ID
>
>outputFileName=outputPath + SUBSTR(DTOS(RunDate), 5) + "_" + "BOGUSTEST.TXT"
>ERASE (outputFileName)
>fh=FCREATE(outputFileName)
>IF fh > 0
> * File creation succeeded! Now, write the header to the text file.
> =FPUTS(fh, lcHeader)
> GO TOP
> SCAN
> * Assemble the text data.
> lc = m.GrpID
> lc = lc + m.GrpNum
> lc = lc + PADR(m.FirstName, 15)
> lc = lc + IIF(EMPTY(m.Initial), " ", m.Initial)
> lc = lc + PADR(m.LastName, 20)
>
Can you post more code from your SCAN loop? May be you're not writing every record?
BTW, you may try using TEXTMERGE instead of creating a string first and then using fputs.
If it's not broken, fix it until it is.
My Blog