Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coverting GOSUB to GOTO?
#10
And for those curious about what's going on here, here's how we do GOUBS:

Code: (Select All)
LABEL_50:;
last_line=50;
if(qbevent){evnt(6);r=0;}
do{
return_point[next_return_point++]=1;
if (next_return_point>=return_points) more_return_points();
goto LABEL_30;

RETURN_1:;
return;

You can see that I've copied the translation starting at the label 50:, and went to the jump point.

If you look closely, you'll see that we have a DO statement in there:

DO...
   set a value in our array for our current return point.
   if we have more points than our array can hold, then redim preserve and make the array larger and hold more return points!
   GOTO the jump point
   Set a label for the RETURN to have a place to return to
   ...

And that's basically how we do things.  We use an internal array to hold the return points, rather than using stack space like QB45 used to do back in the day, but it still creates an endless memory leak that's going to end up making your program self destruct over time, if you don't return back from those gosubs.  It just won't do it anywhere near as fast as a QB64 program will.  Wink
Reply


Messages In This Thread
Coverting GOSUB to GOTO? - by James D Jarvis - 12-30-2022, 06:38 PM
RE: Coverting GOSUB to GOTO? - by SpriggsySpriggs - 12-30-2022, 07:20 PM
RE: Coverting GOSUB to GOTO? - by James D Jarvis - 12-30-2022, 07:47 PM
RE: Coverting GOSUB to GOTO? - by bplus - 12-30-2022, 07:23 PM
RE: Coverting GOSUB to GOTO? - by James D Jarvis - 12-30-2022, 07:44 PM
RE: Coverting GOSUB to GOTO? - by bplus - 12-30-2022, 08:33 PM
RE: Coverting GOSUB to GOTO? - by bplus - 12-30-2022, 07:56 PM
RE: Coverting GOSUB to GOTO? - by SpriggsySpriggs - 12-30-2022, 08:14 PM
RE: Coverting GOSUB to GOTO? - by SMcNeill - 12-30-2022, 11:29 PM
RE: Coverting GOSUB to GOTO? - by SMcNeill - 12-30-2022, 11:41 PM
RE: Coverting GOSUB to GOTO? - by bplus - 12-31-2022, 06:26 PM
RE: Coverting GOSUB to GOTO? - by SMcNeill - 12-31-2022, 07:19 PM
RE: Coverting GOSUB to GOTO? - by James D Jarvis - 12-31-2022, 12:41 AM
RE: Coverting GOSUB to GOTO? - by mnrvovrfc - 12-31-2022, 02:18 AM
RE: Coverting GOSUB to GOTO? - by James D Jarvis - 12-31-2022, 07:13 PM
RE: Coverting GOSUB to GOTO? - by euklides - 12-31-2022, 12:35 PM



Users browsing this thread: 3 Guest(s)