Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Append records to a text file.
Message
 
To
08/09/2003 10:10:59
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00827077
Message ID:
00827085
Views:
14
Try opening/creating the file outside of the scan loop.
Emailfile = "C:\EMAIL.TXT"
IF FILE(Emailfile)  && Does file exist?
      gnErrFile = FOPEN(Emailfile,12)  && If so, open read-write
      = FSEEK(gnErrFile, 0, 2)
ELSE
      gnErrFile = FCREATE(Emailfile)  && If not, create it
ENDIF							

SELE currfile
SCAN
   =FPUTS(gnErrFile,currfile.number)
ENDSCAN
=FCLOSE(gnErrFile)
HTH
cj

>Hi,
>
>[code]
>
>Emailfile = "C:\EMAIL.TXT"
>
>SELE currfile
>SCAN
> IF FILE(Emailfile) && Does file exist?
> gnErrFile = FOPEN(Emailfile,12) && If so, open read-write
> = FSEEK(gnErrFile, 0, 2)
> ELSE
> gnErrFile = FCREATE(Emailfile) && If not, create it
> ENDIF
> =FPUTS(gnErrFile,currfile.number)
>ENDSCAN
>=FCLOSE(gnErrFile)
>[/code]
>
>I am using the code above to write info from a table to a text file. The problem is that it only seems to write the first record to the file and doesn't append the rest. Also I cannot open the file until I close foxpro completely. Anyone know what I'm doing wrong here?
Caroline
Previous
Reply
Map
View

Click here to load this message in the networking platform