87 posts
Posted 02 April 2013 - 04:22 AM
I have a problem with the following code:
function add()
if not fs.isDir("myNotes") then fs.makeDir("myNotes") end
local note = fs.open("myNotes/notes", "w")
print("Type your note.")
print("Or type 'exit' to reboot notes")
note = read()
if note == "exit" then
ask()
else
note.writeLine( note )
note.close()
ask()
end
end
The error is on note.writeLine(note)
1511 posts
Location
Pennsylvania
Posted 02 April 2013 - 04:28 AM
Instead of storing the function read() inside a variable, just do this:
local note = fs.open("lols","w")
print("Type your note")
note.writeLine(read())
note.close()
7508 posts
Location
Australia
Posted 02 April 2013 - 04:28 AM
EDIT: nvm, ninja'd
87 posts
Posted 02 April 2013 - 04:33 AM
Instead of storing the function read() inside a variable, just do this:
local note = fs.open("lols","w")
print("Type your note")
note.writeLine(read())
note.close()
thanks!
Instead of storing the function read() inside a variable, just do this:
local note = fs.open("lols","w")
print("Type your note")
note.writeLine(read())
note.close()
What about the "exit" command?
231 posts
Posted 02 April 2013 - 04:40 AM
Just change note in
note = read()
to some other variable name (like input), and use than same name when you check if its "exit". THat way it won't overwrite the opened file which is stored to note
87 posts
Posted 02 April 2013 - 04:43 AM
Just change note in
note = read()
to some other variable name (like input), and use than same name when you check if its "exit". THat way it won't overwrite the opened file which is stored to note
Odd. It works.
1511 posts
Location
Pennsylvania
Posted 02 April 2013 - 04:52 AM
EDIT: Ninja'd
EDIT: nvm, ninja'd
Heh :P/>