!pr0
!lm12
!rm75
Generalized GOTO and GOSUB.................Bob Sander-Cederlof

Tim Mowchanuk, a lecturer at Brisbane College in Australia, sent the following suggestion:

!lm+5
"How can I implement a named GOTO or GOSUB routine?  There are numerous routines that implement computed GOTO/GOSUB, but I consider that a futile exercise.  Computed GOTO/GOSUB mess up renumbering utilities, and violate modern trends toward structured programming.

"What I really want is something that will handle BASIC like

       100 & GOSUB NAME$

where NAME$ holds the name of a subroutine.  I envision subroutine names being defined by a special REM statement of the form

       200 REM "SUBROUTINE NAME"

The &GOSUB or &GOTO processor can search through the program for a line beginning with a REM token.  If the first non-blank after the REM token is a quotation mark, the processor can compare the characters to the string value.  If there is an exact match, the line containing the REM is the target for the &GOTO or &GOSUB."
!lm-5

The problem sounded just the right size for an interesting AAL article, so I started trying to write some code.

I published an &GOSUB routine back in April 1981 of the type that Tim thinks futile.  The following program combines the two "futile" computed &GOSUB and &GOTO routines with two new ones that allow the computed value to be a string expression.  If the expression after &GOTO or &GOSUB is numeric, the processor will search for a matching line number.  If the result is a string, the processor will search for a REM label as Tim described above.

Only REM's at the beginning of a numbered line will be considered as labels.  The label must be included in quotation marks.  Spaces are OK between the word REM and the first quotation mark.  Anything after the second quotation mark will be ignored.

You can now write a menu program that uses the actual command word as the name of a subroutine, and cease worrying about line numbers.  The accompanying Applesoft program is an example of just such a technique.

