Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File I/O
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
File I/O
Miscellaneous
Thread ID:
00408012
Message ID:
00408012
Views:
44
Can anyone tell me if there is an advantage to writing to a text file between the following two methods:
( I am writing some logging messages during program operation )

(The obvious here is that method 2 seems simpler. but what about reliability or performance?)


method 1
------------------------
tcFile = "logfile.log"
strNewString = "some text here"

IF FILE(tcFile) && Does file exist?
jnH = FOPEN(tcFile,12) && If so, open write only un-buffered
fseek( jnh, 0, 2) && move to end of file
ELSE
jnH = FCREATE(tcFile) && If not, create it
ENDIF
IF jnH < 1 && Check for error opening file
WAIT 'Cannot open or create log file' WINDOW NOWAIT
ELSE && If no error, write to file
Fputs(jnH, strNewString)
ENDIF
FCLOSE(jnH) && Close file


method 2
------------------------

strNewString = "some text here"

Set TextMerge On NoShow
Set TextMerge To "logfile.log" Additive
\<>
Set TextMerge To
Set TextMerge Off
Thanks

- best regards, Robert
Next
Reply
Map
View

Click here to load this message in the networking platform