Jump to content




Need help with window error


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

#1 s0r00t

  • Members
  • 61 posts

Posted 16 April 2014 - 09:41 PM

Hello,
I am encountering an error with window api that crashes the pocket computer. This is the error :
window:57:Expected number
And here is the full code of the program (yes, it is the Improved ToDo list) :
http://pastebin.com/FpMjPiAc
I just know that the error comes from here :
if fs.exists("/.todocfg") then
	opfile = fs.open("/.todocfg", "r")
	local color1 = tonumber(opfile.readLine())
	local color2 = tonumber(opfile.readLine())
	opfile.close()
else
	local color1 = colors.lime
	local color2 = colors.white
end
If I add :
	local color1 = colors.lime
	local color2 = colors.white
after the condition, it works.

Where is the problem?

Thanks!

#2 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 16 April 2014 - 09:47 PM

It's because color1 and color2 are being localized to that if statement. Just create them at the start of your program and then set them in your if statement:

Start of the program:
local color1 = colors.lime
local color2 = colors.white

If statement:
if fs.exists("/.todocfg") then
  local opfile = fs.open("/.todocfg", "r") --// Localizing this wouldn't hurt

  color1 = tonumber(opfile.readLine())
  color2 = tonumber(opfile.readLine())

  opfile.close()
end


#3 s0r00t

  • Members
  • 61 posts

Posted 16 April 2014 - 09:51 PM

Wow, very fast answer !
I didn't thought about that solution, got angry after seeing this error a dozen times :lol:
Thanks a lot !





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users