Project

General

Profile

Actions

Bug #888

closed

On n Gosub and On n Goto function incorrectly.

Added by Brian Flanagan almost 3 years ago. Updated almost 3 years ago.

Status:
Rejected
Priority:
High
Assignee:
-
Target version:
Start date:
01/30/2022
Due date:
% Done:

0%

Estimated time:
Affected version:

Description

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
Actions

Also available in: Atom PDF