Jump to content




Reading File Set:14: Attempt To Index ? (A Nil Value)


  • You cannot reply to this topic
2 replies to this topic

#1 theeboris

  • Members
  • 59 posts
  • LocationThe Nethelands

Posted 06 August 2013 - 04:23 AM

Hello,

I'm busy with a program that make it possible for people to chance settings in LightOS (It is still not released). But if I use this code I get the error message: "set:14: attempt to index ? (a nil value)" . So if I do ap = h.readLine() then it returns nil, but why? I thought that this would be okay. Can somebody help me with this? Thanks :D

acreenx, screeny = term.getSize()
painttools.fill(1, screenx, 1, screeny, 256)
if fs.exists(".lightos/system/config/bluescreen") == false then
local sFile = ".lightos/system/config/bluescreen"
h = fs.open(sFile, "w")
  h.writeLine("false")
  h.writeLine("true")
  h.writeLine("true")
h.close()
end
while true do
local sFile = ".lightos/system/config/bluescreen"
h = fs.open("sFile", "r")
  ap = h.readLine()
  se = h.readLine()
  er = h.readLine()
h.close()
term.setCursorPos(1,1)
print("Auto pastebin:"..ap)
print("Smiley:"..se)
print("Error report:"..er)
--Here comes some more code if the file thing works
end


#2 svdragster

  • Members
  • 222 posts
  • LocationGermany

Posted 06 August 2013 - 06:14 AM

acreenx, screeny = term.getSize()
I think you mean screenx :P

Also
h = fs.open("sFile", "r")
should be
h = fs.open(sFile, "r")
Or it would open a file called "sFile" instead of opening ".lightos/system/config/bluescreen"

#3 theeboris

  • Members
  • 59 posts
  • LocationThe Nethelands

Posted 06 August 2013 - 06:55 AM

Wow! Thanks bro :D That you have see that. Good job :D I give you credits in the .lightos/about.txt and topic if I publish it ;)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users