## "ON k GOTO …" would be attractive

Ideas for improvement
Dutchman
Posts: 148
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

### "ON k GOTO …" would be attractive

ON k GOSUB or GOTO?
In the following code is a Load function that I will use in a lib under development.

Code: Select all

``````'Load data
'by Ton Nillesen, November 2019
'load a section of data from a list into a series of variables
'
DIM List()=(0,1,2,3,4,5,6,7,8,9)
p=4
PRINT "a =";a
PRINT "b =";b
PRINT "c =";c
PRINT "....."
PRINT "f =";f
END
'
' return N values from a() starting at index i
' 0<N<=10
IF N=1 THEN RETURN a(i)
IF N=2 THEN RETURN a(i) a(i+1)
IF N=3 THEN RETURN a(i) a(i+1) a(i+2)
IF N=4 THEN RETURN a(i) a(i+1) a(i+2) a(i+3)
IF N=5 THEN RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4)
IF N=6 THEN RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5)
IF N=7 THEN RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6)
IF N=8 THEN RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6) a(i+7)
IF N=9 THEN RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6) a(i+7) a(i+8)
IF N=10 THEN RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6) a(i+7) a(i+8) a(i+9)
END DEF
'
[this does not work
' return N values from a() starting at index i
' 0<N<=10
ON N GOTO 1,2,3,4,5,6,7,8,9
1: RETURN a(i)
2: RETURN a(i) a(i+1)
3: RETURN a(i) a(i+1) a(i+2)
4: RETURN a(i) a(i+1) a(i+2) a(i+3)
5: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4)
6: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5)
7: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6)
8: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6) a(i+7)
9: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6) a(i+7) a(i+8)
10: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6) a(i+7) a(i+8) a(i+9)
END DEF
]
``````
At the end is an alternative in which I would like to use the "ON n GOTO ..." statement as a variant of the "ON n GOSUB ...".
"ON n GOSUB" does not work because then the RETURN values are not in the last RETURN statement.
Could the varianr "ON n GOTO ..." be added to the language?
It is still a long way to go

kibernetik
Posts: 131
Joined: Tue Aug 06, 2019 3:03 pm

### Re: "ON k GOTO …" would be attractive

There is ON GOTO statement. Documentation, page 18.

Dutchman
Posts: 148
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

### Re: "ON k GOTO …" would be attractive

Oops, I still had doc version 1.5
Thanks
It is still a long way to go

kibernetik
Posts: 131
Joined: Tue Aug 06, 2019 3:03 pm

### Re: "ON k GOTO …" would be attractive

Yes, doc v1.5 is currently the latest version.
The ON GOTO statement is implemented from the very beginning, since version 1.0.

kibernetik
Posts: 131
Joined: Tue Aug 06, 2019 3:03 pm

### Re: "ON k GOTO …" would be attractive

If I comment-out the first
and de-comment the second
then everything still works fine.

If you experience some difficulties with that code sample then please let me know.
On my side it works fine in both cases.

Dutchman
Posts: 148
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

### Re: "ON k GOTO …" would be attractive

kibernetik wrote:
Mon Nov 04, 2019 2:05 pm
On my side it works fine in both cases.
Yes, I discovered that too
I tested both versions in different programs. Something must have gone wrong there.
However, I can no longer reproduce it, the test programs have been deleted.
Sorry for the unnecessary time you took for this non-issue.
It is still a long way to go

kibernetik