Posted 26 November 2013 - 07:26 PM
Hello all. I was trying to create a script that would write strings to a file. I wanted the program itself to be able to utilize arguments to streamline manual control. The program doesn't throw any errors at me, it just refuses to write any strings to the designated file:
the program itself would be called "writer", so I'd type this into the command line…
> writer a file "hello, world!"
I was hoping someone might tell me what I'm doing wrong.
Edit: I've updated the post to address Lyqyd's question
the program itself would be called "writer", so I'd type this into the command line…
> writer a file "hello, world!"
local tArgs={...}
function write(path,mode,str)
str=tostring(str) --tostring() functions for redundancy
mode=tostring(mode)
path=tostring(path)
local file=fs.open(path,mode)
file.writeLine(str)
file.close()
end
write(tArgs[2],tArgs[1],tArgs[3])
I was hoping someone might tell me what I'm doing wrong.
Edit: I've updated the post to address Lyqyd's question
Edited on 03 December 2013 - 05:43 PM