fileopen

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
4NT V8

fileopen[file,w,b]

"w"rite appears to make no difference if file exists but seems to behave as tho
"a"ppend is in affect
I would expect the file empty with "w"rite parameter

example from help file altered to show above.

do r=14 to 8 by -1
set h=%@fileopen[myfile.txt,write,b]
echo writing %@filewriteb[%h,%r,this is a test] bytes
echo closing handle #%h: %@fileclose[%h]
enddo
 
#2
Rex Clark wrote:
| 4NT V8
|
| fileopen[file,w,b]
|
| "w"rite appears to make no difference if file exists but seems to
| behave as tho "a"ppend is in affect
| I would expect the file empty with "w"rite parameter

The @fileopen[] function does not behave the same way as the standard C
library function fopen() for files that already exist. It simply opens the
file for overwriting. Since 4NT/TCMD version 6 the @TRUNCATE function has
been made available to shorten the file.
--
HTH, Steve