Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Expected <eof>, got end | This means..?

Asked by
Xershy 0
6 years ago
Edited 6 years ago

What does this error mean, also thank you if you responded. It may seem so simple to some of you, but I just got into scripting, so yeah.

1 answer

Log in to vote
0
Answered by 6 years ago

"Expected <eof>, got [somthing or other]" means that you probably have an extra "end" somewhere in your code, which is ending the function before you probably want it to.

function lol()
    if true == false then
        print("This is impossible :P")
        end --1
    end --2
    print("If you see this, I'm fixed!")
end --3

In this example, the function lol() ends at "end" number 2, instead of "end" number 3 like we want it to. The problem is "end" number 1, which might of been left over from some previous code. To fix the error, go through your code and make sure each of your if, for, while, etc... statements has only 1 matching "end" statement. Keeping code correctly indented really helps with this.

Do this:

function lol()
    if true == true then
        print("Always true")
        for i = 1, 10 do
            print(i)
        end
    elseif true == false then
        print("IMPOSSIBLE!")
    end
end

Not this:

function lol()
if true == true then
print("Always true")
for i = 1, 10 do
print(i)
end
elseif true == false then
print("IMPOSSIBLE!")
end
end

Good code organization habits will really pay off in the long run, when you have hundreds of lines all blending together. Good luck!

If I've solved your problem, be sure to mark my answer correct :)

1
also <eof> stands for end of file, so if you see <eof> it means the error is near the end LegitimatlyMe 519 — 6y
0
Yeah, not just "somewhere" in your code. hiimgoodpack 2009 — 6y
0
Not necessarily. I've had it before where an extra end in an if statement near the middle of my code completely messed up the ordering of the code and gave me this error. What's important is not just getting rid of the error, it's preserving the code structure. That's why I put "somewhere" instead of "near the end", as the actual problem isn't always at the end of code. whenallthepigsfly 541 — 6y
0
Those functions would never work. You never called them Subaqueously 11 — 6y
0
They functions are an illustration. They do nothing. The point was simply to explain what causes the EOF errors. whenallthepigsfly 541 — 6y
Ad

Answer this question