Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Appending text to low level file
Message
De
01/07/1999 09:42:17
Kenneth Downs
Secure Data Software, Inc.
New York, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00236407
Message ID:
00236426
Vues:
13
Christian,

For complete safety, you'd want to handle both a new file and an append, so something like this does the trick:
LOCAL lnFileHandle,lcFileSpec
lcFileSpec = "X:\SomeDir\Log.txt"

IF FILE(lcFileSpec)
  lnFileHandle = FOPEN(lcFileSpec,2)  &&--Buffered Read/Write
  =FSEEK(lnFileHandle,0,2)   &&--Move zero positions from EOF
ELSE
  lnFileHandle = FCREATE(lcFileSpec)
ENDIF

DO WHILE MyLoggingCondition
  =FPUTS(lnFileHandle,"My Log text")
ENDDO

=FCLOSE(lnFileHandle)
The trouble with text log files like this is that they can't be shared, so the approach you take has to allow for that.

Also check out STRTOFILE() and FILETOSTR(), it's good to be aware of these before you set your approach in stone, they may be useful.

Hope this helps.

>Hello,
>I want to create a error log file, but I don't know how to write to a file without loosing the existing text.
>Is there a easy way to write "additive" to file?
>Thanks for your help!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform