Quote Originally Posted by AndrewC View Post
I'm looking for GO GO Guru

In pbp, what are the tradeoffs between using GOTO or GOSUB to branch to different areas of code ? Does one use more memory than the other ? Is there a limit to how many GOSUBs that can be nested ?

I have some distant memory that you should only use GOTO within a specific (sub)routine and it is better to use GOSUB rather than GOTO to jump to / use a specific code segment. Obviously as well GOSUB will return you to where you started whereas with GOTO you can jump A>B>C>A.

Also, I often use a WHILE - WEND loop for 3 button menu control, is it better to use GOTO or GOSUB here:

WHILE Switch_1 = 1
IF Switch_2 = 0 then GOSUB Label X
IF Switch_3 = 0 then GOSUB Label Y
WEND


Thanks, Andrew
Using Gosub or Goto is NOT a style question. It is a FLOW question.

You use Gosub when you want to Return as soon as the routine is done.

Use Goto to depart your routine, "never" to return. (Although you can start it over later.)