![]() |
|
Compile error - INKEY$ can't be called in a FOR loop - Printable Version +- Boriel Basic Forum (https://forum.boriel.com) +-- Forum: Compilers and Computer Languages (https://forum.boriel.com/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://forum.boriel.com/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://forum.boriel.com/forumdisplay.php?fid=16) +---- Thread: Compile error - INKEY$ can't be called in a FOR loop (/showthread.php?tid=705) |
Compile error - INKEY$ can't be called in a FOR loop - mathez - 2015-11-19 Hello, I am using version 1.3.0-s1121, though I've also tried 1.4.0s1967, and have the following simple program: Code: 10 FOR l = 1 to 30test.bas:6: Syntax Error. Unexpected token 'NEXT' <NEXT> test.bas:7: Undeclared label "10" I am a C/C++ programmer, so I might be missing something but looks like if I have INKEY$ in a FOR loop, it doesn't compile. I can remove the GOTO 10 and do a 10: to fix the second error, though that's not very clean syntax with the line number having to be converted to a label. But, I haven't yet found a workaround for the INKEY$ problem in a FOR loop. Thanks so much for the help. Re: Compile error - INKEY$ can't be called in a FOR loop - boriel - 2015-11-22 The problem here is that the IF THEN is now a composed sentence. You must use END IF, to finish it (think of THEN and END IF as { and } in C++). So your code should be: Code: 10 FOR l = 1 to 30Code: 10 FOR l = 1 to 30 , instead of line numbers (line numbers are just considered labels here).
|