<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Tue, 01 Jul 2003 19:30:17 +0100
From   : Sprow <info@...>
Subject: Re: BASIC 4 bug and more on the ON keyword!

In article <50DA4D126823D411AE2600508B5E2B5A013BCAC0@...>,
   "Fewell, Steve" <Steve.Fewell@...> wrote:
> Hi all,
>
> Is anyone else aware of this bug in BBC BASIC?
> 10 A%=1000
> 20 J%=1
> 30 ON A% GOTO 50,60,70:IF J%=1 PRINT"J%=1" ELSE PRINT"J%=0"
> 40 PRINT"40":END
> 50 PRINT"50":END
> 60 PRINT"60":END
> 70 PRINT"70":END
>
> When running this program the output is:
> J%=0    [which is incorrect!]
> 40

This is correct(ish).See page L2-45 of the Master Manuals.

What's happening is that as the value of A% is not one of the elements after
the GOTO (A%=4 should also trigger the response) it scans forward looking
for an 'ELSE' statement and executes it.The next line in the program is 40
so that gets run too.

It's slightly dubious that the search wasn't terminated by the interpreter
finding the "IF" and the "PRINT" tokens on the way there - it seems to use a
'search and destroy' policy when looking for the ELSE.

There is a warning about using multiline statements on the page I refer to,
Sprow.
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>