View Single Post
Old 10 June 2018, 08:09   #119
Shatterhand
Warhasneverbeensomuchfun
 
Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
Quote:
Originally Posted by MickGyver View Post
I haven't found one, been looking for the same. Maybe you can use a Goto to jump to a label just outside of the loop? I have no idea if that would "break" anything. Somebody more of an expert on BB will probably answer.
I believe with the FOR...NEXT you can just change the value of the looping variable so its condition won't be true again. Didn't try it out, but it should work.

For the while, I end up using another variable on the While condition, and change it when I want to leave the loop.. but this adds a new check every iteration of the loop. There should be some smarter way to do it.


NEW QUESTION:

Is there some way to create an "array of subroutines"?

Like, I have 20 subroutines (each one under a different label), and I want to execute one depending upon the value of a variable.

So instead of using a
Code:
Select AAA

case 0
  gosub routine0
case 1
  gosub routine1
...
case 19
  gosub routine19

End Select
which will be slow as hell (and actually smarter doing somekind of tree structure)

Could I just use something like

Code:
GOSUB routine(A)
Any ideas if its possible to implement something like this?
Shatterhand is offline  
 
Page generated in 0.13159 seconds with 11 queries