On n Gosub and On n Goto function incorrectly.
The expression tested should return a number between 1 and the number of items being checked.
The AOZ documentation examples are correct, but the description is wrong.
According to the AOZ (and AMOS) help, this code:
On X Goto LABEL1,LABEL2,LABEL3
...should be the equivalent of this:
If X=1 Then Goto LABLE1 If X=2 Then Goto LABEL2 If X=3 Then Goto LABEL3
In other words, On X should jump to the Xth item in the list.
Right now, they're all offset by one.
Here's an example:
Palette $000000,$FFFFFF,$FFFF00 Do Pen 1 : Paper 0 Print Input n If n < 1 Or n > 3 Gosub OutOfRange Else Gosub InRange End If On n Gosub 100,DoIt,Quit Wait Vbl If done Then Exit Loop End 100 If n<>1 Then Gosub WrongJump Print "This should be the jump for 1." Return DoIt: If n <> 2 Then Gosub WrongJump Print "This should be the jump for 2." Return Quit: If n<> 3 Then Gosub WrongJump Print "This should be the jump for 3." done=true Return InRange: Print n;" is in range." Return OutOfRange: Pen 2 : Print n;" is out of range! (No jump should occur.)" : Pen 1 Return WrongJump: Pen 2 : Print "Wrong jump performed!" : Pen 1 Return
Updated by Brian Flanagan almost 2 years ago
I understand it being a "base index" issue... but that is not justification for outright rejection.
This is still a bug that needs to be addressed!
If we're going to have anything non-standard / illogical as a part of the language, we should at least provide a method of making the language work normally, as we did with String Base Index n
That's why I suggested adding:
On Base n
...where n = 0 or 1
...so we can specify whether we want the Nth or the N-1th item for On n Gosub and On n Goto.
(N-1 still still seems totally illogical.)