Search code examples
gotobasic

GOTO/OF in HP Time-Shared BASIC


For the following code in HP Time-Shared BASIC, I am wondering about line 2270:

2180  INPUT X
2190  IF X=1 THEN 2210
2200  LET X=2
2210  LET X=X+1
2220  IF X=3 THEN 2260
2230  IF B>39 THEN 2260
[irrelevant code lines removed for clarity]
2260  X1=X1*(-1)
2270  GOTO X OF 2290,2540,2720

Based on other examples in this code base, it seems GOTO [variable] OF [line1,line2,...] seems to be the equivalent of if X == 1 GOTO LINE 1; if X == 2, GOTO LINE 2, etc.

I found the relevant Wikipedia bit "Calculated flow-control via the GOTO/OF and GOSUB/OF statements" but I'd like more clarity.

Can anyone confirm?

Thanks,

Caleb


Solution

  • Thankfully, the Wikipedia page has a link to all the original documentation:

    http://www.bitsavers.org/pdf/hp/2000TSB/

    This includes a full language reference:

    http://www.bitsavers.org/pdf/hp/2000TSB/22687-90001_AccessBasic9-75.pdf

    Which says this about GOTO/OF on page 11-40

    GO TO numeric expression OF statement number list

    ...

    When the second form of the GO TO statement is used, the numeric expression is evaluated and rounded to an integer "n". Control then is transferred to the "nth" statement number in the statement number list, where statement number list is one or more statement numbers separated by commas. If there is no statement number corresponding to the value of the numeric expression, the GO TO statement is ignored and the statement following the GO TO statement is executed

    That appears to confirm your guess