Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exiting a FOR/NEXt loop
#4
(08-24-2022, 06:17 AM)Circlotron Wrote: It certainly did exit the loop. I'm just surprised that it didn't treat the GOTO following the colon as the next instruction and follow it instead. Just now I tried it on QBASIC and it does the same thing. Oh well...
This is what you expected the program to do:
Code: (Select All)
Cls
For x& = 1 To 10
    Print x&
    If x& = 5 Then Exit For
Next x&

If x& = 5 Then GoTo stuff

Print "done"
here: GoTo here

stuff:
Print "exited loop"
Check out the line right below "next x&"...
Reply


Messages In This Thread
Exiting a FOR/NEXt loop - by Circlotron - 08-24-2022, 05:40 AM
RE: Exiting a FOR/NEXt loop - by SMcNeill - 08-24-2022, 05:50 AM
RE: Exiting a FOR/NEXt loop - by Circlotron - 08-24-2022, 06:17 AM
RE: Exiting a FOR/NEXt loop - by mnrvovrfc - 08-24-2022, 06:33 AM



Users browsing this thread: 3 Guest(s)