Jump to content




[Error] [lua] Eof expected?


28 replies to this topic

#1 deity12

  • New Members
  • 19 posts

Posted 14 June 2012 - 07:22 AM

Right, so I"m learning to code and this is just about to make me give up it's giving me so much frustration.
Eof expected? Right so end of function. So it's saying there needs to be an end to my function? But there is one?
E.g. (wrote this simple as hell program to demonstrate what I'm talking about)
Btw I'm still not sure how to colour the text and put it in that box so its easier to read like everyone else so I'm just gonna have to put a wall of text :L.

func = shaft()
if turtle.detectdown(7)
then
end
ekse
turtle.digdown()
shaft()
end

So I know that the problem is with my ends. Also, I really would prefer being shown how to do ends properly rather than just being corrected Thanks in advance!

#2 BigSHinyToys

  • Members
  • 1,001 posts

Posted 14 June 2012 - 08:06 AM

I need the code you are working on before I can find the problem.

Question
do you edit in CC or outside of it with some other IDE / text editor ?? I personally use notepad++

#3 Pinkishu

  • Members
  • 484 posts

Posted 14 June 2012 - 11:35 AM

You have "ekse" there, needs to be "else"
and iirc it was case senstiive so digDown not digdown
besides that script does not make sense?

Looks like you're trying recursion, might be better to use a loop though

#4 BigSHinyToys

  • Members
  • 1,001 posts

Posted 14 June 2012 - 11:57 AM

View PostPinkishu, on 14 June 2012 - 11:35 AM, said:

You have "ekse" there, needs to be "else"
and iirc it was case senstiive so digDown not digdown
besides that script does not make sense?

Looks like you're trying recursion, might be better to use a loop though

View Postdeity12, on 14 June 2012 - 07:22 AM, said:

E.g. (wrote this simple as hell program to demonstrate what I'm talking about)
this is not the code he is working on fixing it will not be useful. is why i asked for the actual code so i can find where the missing "end" is or miss placed "end"

[EDIT]
--response to bellow post--
thank you Pinkishu for reminding me I accidentally confused EOF with END error's
[/EDIT]

#5 Pinkishu

  • Members
  • 484 posts

Posted 14 June 2012 - 01:33 PM

Eof expected actually means theres an end too much, it expects the end of the file but theres another end it cannot link up to something

detectDown(7) doesn't make much sense to me either or is it of any use to put the 7 there?

lets use "scope levels"
func = shaft() -- Scope Level 0
if turtle.detectdown(7) -- Scope Level 0
then -- Scope Level 0->1
end -- Scope Level 1->0
ekse -- fail (lets assume its else) Scope Level 0->1 (notice, theres no if to even link up to since it ended there ^)
turtle.digdown() -- Scope Level 1
shaft() -- Scope Level 1
end - Scope Level 0

So it expects EOF instead of an else since there no if to link it too since it ended the line before

#6 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 14 June 2012 - 04:48 PM

The problem is the function definition is wrong, it should be like:
function <FunctionName>()
  -- code
end
-- or
<FunctionName> = function()
  -- code
end


#7 BigSHinyToys

  • Members
  • 1,001 posts

Posted 14 June 2012 - 04:56 PM

View PostMysticT, on 14 June 2012 - 04:48 PM, said:

The problem is the function definition is wrong, it should be like:
function <FunctionName>()
  -- code
end
-- or
<FunctionName> = function()
  -- code
end
facepalm

No one is reading the above text. it is Pseudo code that does nothing. To fix the problem he would need to post his ACTUAL CODE.

#8 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 14 June 2012 - 05:02 PM

View PostBigSHinyToys, on 14 June 2012 - 04:56 PM, said:

View PostMysticT, on 14 June 2012 - 04:48 PM, said:

The problem is the function definition is wrong, it should be like:
function <FunctionName>()
  -- code
end
-- or
<FunctionName> = function()
  -- code
end
facepalm

No one is reading the above text. it is Pseudo code that does nothing. To fix the problem he would need to post his ACTUAL CODE.
And did you read it?

View Postdeity12, on 14 June 2012 - 07:22 AM, said:

E.g. (wrote this simple as hell program to demonstrate what I'm talking about)
Where does it say it's pseudo-code?

View Postdeity12, on 14 June 2012 - 07:22 AM, said:

Right so end of function. So it's saying there needs to be an end to my function? But there is one?
If he is really trying to declare functions like that, that's the problem.
But yes, he has to post the actual code so we can see the error.

#9 BigSHinyToys

  • Members
  • 1,001 posts

Posted 14 June 2012 - 05:09 PM

the problem he is having is a "Eof expected" error there is no "Eof expected" error in the code he posted (yes there are other problems with it)

the code he posted is a example of a problem cant be fixed from the example code he posted. the func is just lazy doing it in a pseudo way in a demonstration. I would put money on it that in his code he uses the correct "function = exampleName()" syntax

#10 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 14 June 2012 - 05:19 PM

View PostBigSHinyToys, on 14 June 2012 - 05:09 PM, said:

the problem he is having is a "Eof expected" error there is no "Eof expected" error in the code he posted (yes there are other problems with it)
Really?
func = shaft() -- attempt to call nil
if turtle.detectdown(7)
then
end
ekse -- = expected (or something else)
turtle.digdown() -- attempt to call nil
shaft() -- attempt to call nil
end -- EOF Expected
The first errors don't matter, since they would never get executed, but the "eof expected" is there.

#11 BigSHinyToys

  • Members
  • 1,001 posts

Posted 14 June 2012 - 05:28 PM

there is one pseudo function deceleration and an matching end for it and one if statement with a end for it. there is the correct number of ends to match meaning no "Eof expected" error.

pseudo code is not designed to be executed but for ruffing out a programs flow of command's allowing for change in design before a single real section of code is ever typed. his code is ether a total fail or pseudo code (where func represents a function call and shaft() represents a function that would be called that digs or interacts with a shaft of some kind.)

#12 Pinkishu

  • Members
  • 484 posts

Posted 14 June 2012 - 05:37 PM

well the problem is that the if ends and then he tries to do an else
try it :(/>

#13 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 14 June 2012 - 05:37 PM

Yes, pseudo code. We get it. You're not understanding that if the function declaration he's using there is the way he's declaring the function in the actual code, that's a problem. Of course we need to see the actual code, but if we are asked to debug based on pseudo code, you don't just blatantly make assumptions that the actual code is more correct than the pseudo code. You especially don't pick and choose which elements to assume they got correct in the actual code.

#14 Pinkishu

  • Members
  • 484 posts

Posted 14 June 2012 - 05:40 PM

Well he says he wrote this program... so it might be real code that he just typed from ingame and typo'ed else? :(/>

#15 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 14 June 2012 - 05:49 PM

View PostPinkishu, on 14 June 2012 - 05:40 PM, said:

Well he says he wrote this program... so it might be real code that he just typed from ingame and typo'ed else? :(/>

I wasn't originally replying to you, by the way. You snuck that post in whilst I was typing!

That bit of code up there has deeper issues than a typo'd else or a broken function declaration. It lacks understanding of if structures, for one thing.

I'd bet the EOF error is more related to the overuse of ends inside ifs than anything else (despite the fact that this one would match up fine if the function declaration was valid). I assume there are enough mismatched ifs and not enough missing ends elsewhere so that we are reaching an end after the closing end.

#16 BigSHinyToys

  • Members
  • 1,001 posts

Posted 14 June 2012 - 05:51 PM

I concede on all fronts. His code is complete fail

#17 Pinkishu

  • Members
  • 484 posts

Posted 14 June 2012 - 05:51 PM

Uhm this one would not be fine at all? lol
if then end else will never work :(/> unless there was another if above it maybe

#18 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 14 June 2012 - 05:57 PM

View PostPinkishu, on 14 June 2012 - 05:51 PM, said:

Uhm this one would not be fine at all? lol
if then end else will never work :(/> unless there was another if above it maybe

Heh. Who said it was fine?

#19 deity12

  • New Members
  • 19 posts

Posted 15 June 2012 - 03:25 AM

Ok, right lot of stuff to reply to.
Firstly, the reason i typed that instead of my actual code id that I get that sort of error with a lot of things i try to code. If somebody just corrects my code, that only fixes one problem, and one code. What i was really asking for was how do I use 'end' properly. It's a real killer for any coding I attempt. And yes, agreed the code I posted was complete crap, I know that and I have made much better codes, but the best I can do is sustitute from someone else's code because i can't change some things because of 'eof expected'. Basically I would like to either be taught when and how 'end' should be used or pointed to somewhere that can show me how. And yes, I was just being lazy there and typo'd/typed incorrect synatx. I ahve tried many, many different ways of arranging my ends but none seem to work.

#20 Pinkishu

  • Members
  • 484 posts

Posted 15 June 2012 - 09:18 AM

Then correct that code?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users