Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compile error - INKEY$ can't be called in a FOR loop
#2
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 30
IF INKEY$ <> "" THEN GOTO 100: END IF
NEXT l
GOTO 10
100 PRINT "*"
Actually, THEN can be omitted, and you can insert many sentences, each in a new line:
Code:
10 FOR l = 1 to 30
IF INKEY$ <> "" THEN
   REM You can put many sentences here
   GOTO 100
END IF
NEXT l
GOTO 10
100 PRINT "*"
Also, you can use Labels (e.g. MyLabel: ) ending them in with a colon (Smile, instead of line numbers (line numbers are just considered labels here).
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)