This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
IAmTheRad's profile picture

Touchscreen Password

Started by IAmTheRad, 17 February 2013 - 09:29 PM
IAmTheRad #1
Posted 17 February 2013 - 10:29 PM
Topic: Touchscreen Password

Hello, ich have a problem with my new Touchscreen Password programm. May somebody can help me?
The error is:

bios:338: [string "pw"]:94: "<eof>" expected


Here is my code:


passwort = 1218
count = 0
a = 0
b = 0
c = 0
d = 0
eingabe = 0
zugang = 0
function Rahmen()
shell.run("clear")
term.setBackgroundColor(colors.green)
term.setCursorPos(3,2)
print("123")
term.setCursorPos(3,3)
print("456")
term.setCursorPos(3,4)
print("789")
end
term.setBackgroundColor(colors.black)
function Eingabe()
while count < 4 do
event,side,x,y = os.pullEvent()
  if event == "monitor_touch" then
    if x == 3 and y == 2 then
count = count + 1
a = 1
term.setBackgroundColor(colors.black)
write("*")
elseif count == 2 then
b = 1
write("*")
elseif count == 3 then
c = 1
write("x")
elseif count == 4 then
d = 1
write("*")
end
  end
 
    if x == 4 and y == 2 then
count = count + 1
a = 2
term.setBackgroundColor(colors.black)
write("*")
elseif count == 2 then
b = 2
write("*")
elseif count == 3 then
c = 2
write("x")
elseif count == 4 then
d = 2
write("*")
end
  end


    if x == 5 and y == 2 then
count = count + 1
a = 3
term.setBackgroundColor(colors.black)
write("*")
elseif count == 2 then
b = 3
write("*")
elseif count == 3 then
c = 3
write("x")
elseif count == 4 then
d = 3
write("*")
end
  end
 
	  if x == 3 and y == 3 then
count = count + 1
a = 4
term.setBackgroundColor(colors.black)
write("*")
elseif count == 2 then
b = 4
write("*")
elseif count == 3 then
c = 4
write("x")
elseif count == 4 then
d = 4
write("*")
end
  end
	  if x == 4 and y == 3 then
count = count + 1
a = 5
term.setBackgroundColor(colors.black)
write("*")
elseif count == 2 then
b = 5
write("*")
elseif count == 3 then
c = 5
write("x")
elseif count == 4 then
d = 5
write("*")
end
  end
 
	  if x == 5 and y == 3 then
count = count + 1
a = 6
term.setBackgroundColor(colors.black)
write("*")
elseif count == 2 then
b = 6
write("*")
elseif count == 3 then
c = 6
write("x")
elseif count == 4 then
d = 6
write("*")
end
  end
	  if x == 3 and y == 4 then
count = count + 1
a = 7
term.setBackgroundColor(colors.black)
write("*")
elseif count == 2 then
b = 7
write("*")
elseif count == 3 then
c = 7
write("x")
elseif count == 4 then
d = 7
write("*")
end
  end
	  if x == 4 and y == 4 then
count = count + 1
a = 8
term.setBackgroundColor(colors.black)
write("*")
elseif count == 2 then
b = 8
write("*")
elseif count == 3 then
c = 8
write("x")
elseif count == 4 then
d = 8
write("*")
end
  end
	  if x == 5 and y == 4 then
count = count + 1
a = 9
term.setBackgroundColor(colors.black)
write("*")
elseif count == 2 then
b = 9
write("*")
elseif count == 3 then
c = 9
write("x")
elseif count == 4 then
d = 9
write("*")
end
  end
end
count = 0
end
while true do
Rahmen()
Eingabe()
eingabe = (""..a..""..b..""..c..""..d..")
zugang = (passwort-eingbe)
if zugang == 0 then
write("OK")
rs.setOutput("bottom", true)
sleep(2.5)
rs.setOutput("bottom", false)
else write("FALSCH")
end
sleep(3)
term.setBackgroundColor(colors.black)
end

Sorry for my bad english, but I am German :-)
Shrooblord #2
Posted 18 February 2013 - 10:12 AM
First, I recommend using indentations in the future. That helps spot places where you've forgotten to include an 'end' or have placed an end too many, which is what you have done. The <eof> expected error occurs when the program thinks the code should have ended, whereas it does not. This is because you have one too many 'end's in your code somewhere that causes the program to think you've concluded your code with a final end statement.
I checked your code and ran into several superfluous end statements. Here's your code, restructured with indentations. You can see where the ends don't meet up (if you'll pardon my pun).
http://pastebin.com/ZC9Vwuu5

I checked where your ends don't line up, and here you go, in all these lines, there's an end too many.
Lines
98;
117;
136;
154;
172;
191;
195.

You'll have to figure out for yourself which end has to be erased - I don't know where you wanted your actual functions and if and elseif statements to end.

Also look at this part at the end of the code:
Spoiler

while true do
	Rahmen()
	Eingabe()
	eingabe = (""..a..""..b..""..c..""..d..")
   zugang = (passwort-eingbe)
   if zugang == 0 then
	   write("OK")
	   rs.setOutput("bottom", true)
	   sleep(2.5)
	   rs.setOutput("bottom", false)
   else write("FALSCH")
   end
   sleep(3)
   term.setBackgroundColor(colors.black)
end

If you look at the Pastebin link, you'll see the end of the code is all highlighted in red. This is because you are either missing a quotation mark or have one too many.
Look:

eingabe = (""..a..""..b..""..c..""..d..")

That should read

eingabe = (""..a..""..b..""..c..""..d.."")

or

eingabe = (""..a..""..b..""..c..""..d)

(I think).
tesla1889 #3
Posted 18 February 2013 - 11:50 AM
Shrooblord

this forum gets rid of any indentations in any copy-and-pasted text, so its not necessarily his fault

other than that, you are correct on the source of the error
IAmTheRad #4
Posted 19 February 2013 - 09:00 AM
ok, thanks :)/>
Now it's work!