whenever i make a function, such as the one below, and try to run it, pico-8 almost always returns a syntax error, saying something along the lines of "<EOF> EXPECTED AT LINE 23", where line 23 is the last line of the last function in the code.
below shows the framework of the functions i usually code, "blah" obviously being substituted with code.
FUNCTION DOSTUFF() IF BLAH THEN BLAH BLAH BLAH BLAH BLAH BLAH --this line is where an "<eof>" is usually expected END END
It sounds like most of the time you're managing to forget the "then" on your IF BLAH THEN line; an if without a then is treated as a one-liner that in turn requires (and allows) no corresponding END statement.
So, for example, this as the sole content of a program runs fine (and does nothing interesting):
function dostuff() if true then local x = 0 x += 1 end end
Whereas this, without that "then", barfs up the EOF warning you're mentioning:
function dostuff() if true local x = 0 x += 1 end end
@joshmillard: I, too, am guilty of forgetting thens and dos but I'm soon reminded. your last example brings up " 'then' expected near 'local' "
@badatcoding: could you provide a copy/paste example? tried a few things but never got that error.
this one though:
function dostuff() if (true) x = 0 y=2 end end
Syntax error line 3
<EOF> expected near 'END'
should be line 4/5 or "unexpected 'END'" on line 5 I guess...
well I'm often puzzled by error messages in pico8, I think I mostly read 'problem around there' (might be only related to lua though, I don't use it anywhere else so I wouldn't know)
Yeah, the error reporting on these could be clearer -- an "unexpected END on line x" message would be more communicative than just barfing about EOF more generally -- though that's easy for me to say as someone who has never had to implement such a thing. I don't know how much of what exists is native Lua reporting being passed through vs. zep bootstrapping his own error system.
[Please log in to post a comment]