DigitalDunc wrote:
Then I realised that there would be a problem if someone put say for instance a GOTO that went to a nonexistent line... Oh dear.
The same situation would exist for references to non-existent
GOSUB targets. Either way, it shouldn't be a problem. Renumbering a BASIC program is always a relative operation, not absolute. So what you'd do is renumber the broken
GOTO or
GOSUB and it would continue to be broken. It would be the programmer's problem, not yours.
Digressing a bit, in Business BASIC (BB), encountering a broken
GOTO will direct execution to the first statement found after the non-existent one. For example, suppose statements progress from
980 to
990 to
1000. Also, suppose an instruction on
980 conditionally executes
GOTO 991. Rather than halt with an error due to the reference to the non-existent statement, the BB interpreter will execute
GOTO 1000, since that is the nearest statement that is numerically higher than the desired target.
I never really got into EhBASIC because of its Micro-soft BASIC origins. My first exposure to BASIC was in doing development in BB on minicomputers, an activity that progressed to development in Thoroughbred's Dictionary-IV environment. Thoroughbred's BASIC engine allows instructions to refer to labels instead of statement numbers, e.g.,
JSR PRINTCHR instead of
JSR 12345, effectively eliminating the need to refer to statement numbers.
I started doing BB development right before I bought my first computer—a Commodore 64. When I first tinkered with the C-64's BASIC—customized from Micro-Soft's 1970s-era interpreter, I was quite disappointed with its crudeness, as I was accustomed to working with BB and its capabilities. I was also dismayed with the poor floating point accuracy and performance—the "excess 128" format used to represent floating point is notorious for silly conversion errors. Needless to say, I wrote very little software in BASIC on that machine and the C-128s that followed it.
While it might be impractical with a BASIC running on a 65C02, use of labels would likely be feasible with a BASIC written specifically to run on a 65C816 system with extended memory. In such a system, there would be sufficient RAM to store the necessary lookup tables that would correlate a statement such as
JSR PRINTCHR with the target subroutine's address in the program text. Looking up an address in a sorted table goes a lot faster than walking through the program text in search of the target.