128 posts
Location
Poland
Posted 25 November 2012 - 08:56 AM
Code:
local zm = 'zmienne'
term.clear()
term.setCursorPos(1,1)
print "Status Wlaczania: "
if fs.exists(zm) then
term.setCursorPos(1,2)
print "Zmienne [X]"
else
term.setCursorPos(1,2)
print "Zmienne [ ]"
fs.open(zm, "w")
fs.close(zm)
term.setCursorPos(1,2)
sleep(1)
term.clearLine()
print "Zmienne [X]"
end
Error:
startup:12: attempt to call nil
zmienne is in polish in english it means variables :D/>/>
180 posts
Posted 25 November 2012 - 09:01 AM
fs.open returns a file handle, which is what needs passed to close, not the file name.
local h = fs.open(zm, "w")
h.close()
71 posts
Location
Latvia
Posted 25 November 2012 - 09:04 AM
Code:
local zm = 'zmienne' term.clear() term.setCursorPos(1,1) print "Status Wlaczania: " if fs.exists(zm) then term.setCursorPos(1,2) print "Zmienne [X]" else term.setCursorPos(1,2) print "Zmienne [ ]" fs.open(zm, "w") fs.close(zm) term.setCursorPos(1,2) sleep(1) term.clearLine() print "Zmienne [X]" end
Error: startup:12: attempt to call nil zmienne is in polish in english it means variables :D/>/>/>/>
Maybe try this:
local zm = 'zmienne'
term.clear()
term.setCursorPos(1,1)
print "Status Wlaczania: "
if fs.exists(zm) then
term.setCursorPos(1,2)
print "Zmienne [X]"
else
term.setCursorPos(1,2)
print "Zmienne [ ]"
fs.open(zm, "w")
fs.close()
term.setCursorPos(1,2)
sleep(1)
term.clearLine()
print "Zmienne [X]"
end
Tell me if that's what you wanted.
128 posts
Location
Poland
Posted 25 November 2012 - 09:06 AM
OK but when i'm editing file "zmienne" and if i'm click any button it's writing
edit:363: bad argument: string expected, got nil
180 posts
Posted 25 November 2012 - 09:20 AM
Maybe try this:
That is still the same incorrect usage of fs.close. See my above post.
128 posts
Location
Poland
Posted 25 November 2012 - 09:39 AM
This dont work…
180 posts
Posted 25 November 2012 - 10:00 AM
My code is tested and verified, and it works.
If you are getting an error, we need to see both the error and the code to help.
128 posts
Location
Poland
Posted 25 November 2012 - 11:03 AM
180 posts
Posted 25 November 2012 - 11:12 AM
My code was
h = fs.open("newfile", "w")
h.close()
It creates the new file, closes the file handle, and no errors.
2088 posts
Location
South Africa
Posted 25 November 2012 - 01:33 PM
Is the file in rom? If it is, you can't delete it
2005 posts
Posted 26 November 2012 - 07:39 AM
Post the current version of the code, incorporating the repair suggested by dissy, and the error message for that version. Don't tell us you've got new error messages without posting the code that produced them.