The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1677 - File: showthread.php PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/showthread.php 1677 errorHandler->error_callback
/showthread.php 916 buildtree




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)