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

Code Not Working and I Can't See What's Wrong

Started by zaxinvex, 04 October 2015 - 11:31 AM
zaxinvex #1
Posted 04 October 2015 - 01:31 PM
So I was making an OS (And still am, I am NOT cancelling this) and I ran into some errors with the menu. It kept saying: bios:14: [string ".temp":15: '<eof>' expected. I don't know what this means or how to fix it. Here is my code:

local ch1 = read()
if ch1 == 1 then
shell.run("programs")
elseif ch == 2 then
shell.run(".sor")
elseif ch == 3 then
shell.run(".hai")
elseif ch == 4 then
shell.run("news")
end

CAN SOMEONE DECODE THIS? And also tell me any other mistakes I've made… Also, in front of the shell.runs in the actual code I have used the tab button.
valithor #2
Posted 04 October 2015 - 08:04 PM
Could you post all of your code? The error you provided points to line 15, and the code you posted here is definitely not 15 lines. If you type the code into the post by hand, then make sure that you are copying it exactly how it is. Otherwise just provide a pastebin link.

If I remember correctly that error means you have too many ends in your code.
Edited on 04 October 2015 - 06:05 PM
KingofGamesYami #3
Posted 04 October 2015 - 08:11 PM
The code you posted will not throw that error, however it will not work either.

Problem: you get the variable "ch1" from the user, and thereafter refer to the variable "ch" - which is nil because it was never defined.

Problem: read returns a string, which you are comparing against a number. This should help you understand:


print( 1 == "1" )
print( tostring( 1 ) == "1" )
print( 1 == tonumber( "1" ) )
zaxinvex #4
Posted 17 October 2015 - 02:30 AM
Oh thanks.

By the way about that OS, I'm not cancelling it, just making a new format. So this choice business is not used anymore.