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

Program Errors Like <eof> expected

Started by xbeigeninjax, 04 January 2013 - 10:05 AM
xbeigeninjax #1
Posted 04 January 2013 - 11:05 AM
Here is my program:

function doorTrue()
print("Opening Door")
redstone.setOutput("left",true)
sleep(7)
end
function doorFalse()
print("Closing Door")
redstone.setOutput("left",false")
end
on == true
off == false
write "On/Off: "
if input = true then doorTrue()
if input = false then doorFalse()
end

Now, when I try to run this program, it gives me a [string "door"]:13: 'then' expected. I have no idea what I have to do there. Then sometimes, it gives me an error saying [string "door"]:10: "=" expected, but I know that I need on to have to value of true, so I don't change it. And, finally, I sometimes get the error [string "door"]:5: <eof> expected. I don't even know what eof means. Can anyone help?
Lyqyd #2
Posted 04 January 2013 - 11:16 AM
You have comparison and assignment backwards. Where you have ==, it should be = and where you have =, it should be ==.
zekesonxx #3
Posted 04 January 2013 - 11:18 AM
Using = is setting a variable
Using == or === is comparing a variable to another variable.

You either need another 'end' or a 'elseif' in place of the second 'if'

You are checking the 'input' variable but never declaring it

The write function needs (), this isn't PHP.

EDIT: Damn you ninja posts…
Loki #4
Posted 04 January 2013 - 11:19 AM
function doorTrue()
print("Opening Door")
redstone.setOutput("left", true)
sleep(7)
end
function doorFalse()
print("Closing Door")
redstone.setOutput("left",false")
end
input = read()
write ("On/Off: ")
if input == "On" then
doorTrue()
elfeif input == "Off" then
doorFalse()
end

Your code should work fine now, try that^
Loki #5
Posted 04 January 2013 - 11:23 AM
Using = is setting a variable
Using == or === is comparing a variable to another variable.

You either need another 'end' or a 'elseif' in place of the second 'if'

You are checking the 'input' variable but never declaring it

The write function needs (), this isn't PHP.

EDIT: Damn you ninja posts…
You ninja posted me brah.
remiX #6
Posted 04 January 2013 - 08:27 PM
The write function needs (), this isn't PHP.

It doesn't need the ()