Talk:IO (API)

From ComputerCraft Wiki
Revision as of 19:08, 29 September 2012 by 131.191.86.130 (Talk) (Added an answer to the question)

Jump to: navigation, search

What features are trimmed down?

it's kinda useless to say that features are trimmed down, if there's no list. Graypup 01:57, 21 June 2012 (UTC)

Why this code leads to error?

local f=io.open("testfile","w")
io.output(f) --Error "attempt to call nil" - Why? f contains data (table:7a86c)--
io.write(...)
f:close()

  • First off, you need to be more specific as to what you want the code to do. I'm going to assume that you want to write the contents of f to the screen. Based on what I understand from the Lua 5.2 Ref Man, I believe io.output(f) needs to be io.output(f):write(), rather than have them seperate. Regardless of that, I do know for sure you need to read in the contents of your file. (ie. local fdata = f:read(), then you need to io.write/print your fdata)