Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Appending text to low level file
Message
From
01/07/1999 09:42:17
Kenneth Downs
Secure Data Software, Inc.
New York, United States
 
 
To
01/07/1999 09:24:10
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00236407
Message ID:
00236426
Views:
12
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!
Previous
Reply
Map
View

Click here to load this message in the networking platform