[Error] [lua] Eof expected?

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!

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

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.)

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.

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.

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.