File not working in Lua -


i doing small program school in lua, need help. open file, when write, nothing appears in .txt file. can help? snippet of code trying fix:

file=io.open('var.txt',"w+")      io.output(file)      io.write('hi!') 

edit: tried file:close() , io.flush(), haven't managed make work.

try following:

io.output('var.txt') io.write('hi!') io.close() 

the function io.output allows specify current file output filename. in example, passing file handler created io.open instead of filename. implicitly creates bad file handler io.write cannot use.

for more info, check out chapter on "the simple i/o model" "programming in lua".


Comments

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

javascript - Why Selenium can't find an element that is graphically visible -

angular - Angular2 Router: Cannot find primary outlet to load 'HomeComponent' -