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

<eof> expected

Started by hdt80bro, 12 June 2013 - 02:30 PM
hdt80bro #1
Posted 12 June 2013 - 04:30 PM
Title: <eof> expected
I have recently created a voice control programs using misc peripherals. I realize that this isn't a forum or misc peripherals, but I'm 95% sure that it's my coding, and not a problem with misc peripherals. The code and be found here: pastebin.com/iZr7m6CS . I've looked around, and I can't find a solution. The specific error is "bios:337: [string "voiceControl"]:21: '<eof>' expected. Any help would be very helpful.
Lyqyd #2
Posted 12 June 2013 - 05:13 PM
Split into new topic.

The usual cause of that error is having an extra `end` someplace, and the usual cause of that is using if clauses incorrectly. If that is the case, then you'd want to make sure that all of your if blocks have the if / elseif / else / end structure rather than if / end / elseif / end / else / end. I'd look at your code to confirm, but not only is it over on pastebin rather than posted here, but it's also not even a link! :P/>
Kingdaro #3
Posted 12 June 2013 - 05:57 PM
What is the code of your "listen" program? The error points to line 21, which doesn't exist in the code you've given.
Bomb Bloke #4
Posted 12 June 2013 - 07:22 PM
Down the bottom, you have:

listen()
shell.run("listen")

So if I'm understanding this correctly, you call your listening function once, then you have the script run itself (the same script) again.

This won't work, or even if it will, it won't work forever. Every time the script calls itself, the Lua interpreter has to keep track of another running version of the script - none of these ever end, as they're all waiting for yet more instances of the script to end. This will eventually crash your program by way of overflow (you'll max out the RAM Lua reserves for such shenanigans).

Instead use:

while true do
  listen()
end
hdt80bro #5
Posted 12 June 2013 - 10:02 PM
Sorry, I posted the wrong link. The correct on is pastebin.com/iDqyi89d. I have now fixed this, thanks. And thanks for the tip Bomb Bloke.
Bomb Bloke #6
Posted 12 June 2013 - 10:14 PM
Once the peripheral is wrapped to 'p', it stays that way. You don't need to do it again.

You need to rednet.open("WhateverSideTheModemIs") before you can start broadcasting.

This script also has the same issue as the other one you linked.

I can't see any particular reason for the specific error you're getting.
hdt80bro #7
Posted 13 June 2013 - 12:02 AM
I've fixed it now. I had to many ends. I realized I didn't need to wrap anymore, so that's why I stopped. I do rednet.open("left") in startup.