>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
>
The low-level I/O solution gives you more control of I/O buffering and it's easier to trap individual low-level operation failures. It's a bit more cumbersome to write.
>
>method 2
>------------------------
>
>strNewString = "some text here"
>
>Set TextMerge On NoShow
>Set TextMerge To "logfile.log" Additive
>\<
>
>Set TextMerge To
>Set TextMerge Off