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

Help, error 338

Started by Choncy, 17 September 2015 - 09:23 PM
Choncy #1
Posted 17 September 2015 - 11:23 PM
keep getting error — Bios:338:string "clearout":59: '<eof>' expected

term.clear()
term.setCursorPos(1,1)

print("Length: ")
print("Width : ")
print("Height: ")

local length = 0
local width = 0
local height = 0

term.setCursorPos(9,1)
length = read()
term.setCursorPos(9,2)
width = read()
term.setCursorPos(9,3)
height = read()

term.clear()
print("Starting Program…")

turtle.dig()
turtle.forward()

for i=1,height do
for j=1,width do
for k=1,length do
turtle.dig()
turtle.forward()
end
if j ~= width then
if (j%2) == 0 then
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
end
else
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
end
end
end
if i ~= height then
if (width%2) == 0 then
turtle.turnRight()
for p = 1,width do
turtle.forward()
end
turtle.turnRight()
end
else
turtle.turnLeft()
for q = 1,width do
turtle.forward()
end
turtle.turnLeft()
for e = 1,length do
turtle.forward()
end
turtle.turnLeft()
turtle.turnLeft()
end
end
turtle.digUp()
turtle.up()
end

print("Program Completed")
Bomb Bloke #2
Posted 18 September 2015 - 01:38 AM
An "end of file expected" error typically indicates that you've placed "end" statements in the wrong place - if the interpreter finds one it can't match to an if/while/for/whatever block, it assumes your intention is to end the whole script. But if you've written more code after that point then it knows that can't be right either, and so it throws the error.

Indenting your code will help you track where each "end" should be.
Lyqyd #3
Posted 18 September 2015 - 02:58 AM
Technically, it would throw the error as soon as it encounters an end trying to close a block that was never opened, regardless of whether any code follows that end or not. The rest of the information above is correct.
Imred Gemu #4
Posted 18 September 2015 - 05:08 AM
The "end"s at lines 67 and 70 do not go with any ifs/loops/functions. As the others have said, you should press "tab" after every new if/loop/function statements to make it easier to keep track of which end goes to which statement. For example:

if foo == "bar" then
    print(Hello)
    --do some other stuff
end

i = 0
while i < 15 do
    i = i + 1
end