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 #1

Updated by Brian Flanagan almost 3 years ago

  • Affected version set to 1.0.0 (B12) u19
Actions #2

Updated by David Baldwin almost 3 years ago

  • Status changed from New to Rejected

This is a 'base index' issue. It works as you expect with Amiga manifest, however in AOZ manifest, the base index for the first call is zero.

Rejecting on these grounds.

Actions #3

Updated by Brian Flanagan almost 3 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.)

Actions

Also available in: Atom PDF