100 Rem In the following code Line 110 IS a jump table in BASIC (Note most of the functional code is omitted for clarity)
110 On JOY% Goto 200,250,300.350.400,450,500,550,120 (Joy% returns 1 to 8 for direction or 9 if centered)
120 Rem Check for abort (X%=1 when user decides to quit)
140 if x%=0 goto 100
160 Rem shutdown cleanly
180 End
200 Rem Handle Joystick Up-Right
249 Goto 120
250 Rem Handle Joystick Right
299 Goto 120
300 Rem Handle Joystick Dn-Right
349 Goto 120
350 Rem Handle Joystick Down
399 Goto 120
400 Rem Handle Joystick Dn-Left
449 Goto 120
450 Rem Handle Joystick Left
499 Goto 120
500 Rem Handle Joystick Up-Left
549 Goto 120
550 Rem Handle Joystick Up
599 Goto 120
In Sinclair BASIC I would use the following changes.
Line 10 declares J prior to use as required by Sinclair BASIC
10 Let J=1
120 Gosub J
130 Goto 150+J*50
800 Rem Insert code to assign joystick direction to the variable J
<lines j="" variable="" to="" 9="" 1="" range="" the="" in="" value="" appropriate="" assign="" code="" contain="" 801-849="">850 Return</lines>
<lines j="" variable="" to="" 9="" 1="" range="" the="" in="" value="" appropriate="" assign="" code="" contain="" 801-849="">On Joy% Gosub <list> could have been used for this simply by changing the Goto 120 statements to Return statements.
The fall through behavior seen in Case statements can be implemented by omitting the Goto 120 statements from selected code blocks.</list></lines>
<lines j="" variable="" to="" 9="" 1="" range="" the="" in="" value="" appropriate="" assign="" code="" contain="" 801-849=""><list> </list></lines><lines j="" variable="" to="" 9="" 1="" range="" the="" in="" value="" appropriate="" assign="" code="" contain="" 801-849=""><list>The concepts remain the same across languages. What changes is the exact code that is needed to implement the structure. Understanding what a structure element actually DOES is required when using that structure in a language which does not include the concept of the structure you want to use. Case statements for example did not exist in the COBOL dialect I used in school. Implementing the Case structure taught me a lot about how that compiler handled the implied Return tag at the end of procedures :) That particular piece of code was a real WTF :P</list></lines>
<lines j="" variable="" to="" 9="" 1="" range="" the="" in="" value="" appropriate="" assign="" code="" contain="" 801-849=""><list>I prefer using branch to label, but I can work with branch to line number when the compiler/interpreter does not do labels.
GW-BASIC (BASICA) is a good language, but without a resource like Compute! magazine that would teach you how to use it, there is very little you can do with it unless you have already learned how to program using other dialects or languages. Claiming GW-BASIC is lousy because you failed to learn how to use it is placing the blame incorrectly.</list></lines>