io - Lua 4.0.1 appendto -


could please explain proper way use appendto function?

i trying use write debug text file. want written when call function, reason program waits until exits, , writes @ once.

am using right function? need open, write, close file each time write instead?

thanks.

looks having issue buffering (this common question in other languages, btw). data want write file being held in memory buffer , being written disk in latter time (this done batch writes disk together, better performance).

one possibility open , close file suggested. closing file handle flush contents of buffer disk.

a second possibility use flush function explicitly request data written disk. in lua 4.0.1, can either call flush passing file handle

-- if have opened file open: local myfile = open("myfile.txt", "a") flush(myfile)  -- if used appendto output file handle in _output global variable appendto("myfile.txt") flush(_output) 

or can call flush no arguments, in case flush files have open.

flush() 

for details, see reference manual: http://www.lua.org/manual/4.0/manual.html#6.


Comments