FAQ  •  Register  •  Login

Serious bug indexing arrays (*solved*)

<<

einar

Posts: 84

Joined: Sun Apr 08, 2012 9:33 pm

Post Mon Sep 29, 2014 3:48 am

Serious bug indexing arrays (*solved*)

Try running this program:

  Code:
DIM score(1 TO 2) AS UBYTE
DIM player AS UBYTE

LET score(1)=0
LET score(2)=0
LET player = 1
LET score(player)=score(player)+1
PRINT "SCORE ";score(1);"x";score(2)


The result will be "SCORE 0x1". This code was supposed to increment the score for player 1, but it will increment it for player 2 instead!

Now try changing this program as follows:

  Code:
DIM score(1 TO 2) AS UBYTE
DIM player AS UBYTE

LET score(1)=0
LET score(2)=0
LET player = 1
LET score(1)=score(1)+1
PRINT "SCORE ";score(1);"x";score(2)


Now it will give the correct result "SCORE 1x0".

Tested using latest ZX BASIC release 1.4.0s1893.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Mon Sep 29, 2014 7:43 am

Re: Serious bug indexing arrays

einar wrote:Try running this program:

  Code:
DIM score(1 TO 2) AS UBYTE
DIM player AS UBYTE

LET score(1)=0
LET score(2)=0
LET player = 1
LET score(player)=score(player)+1
PRINT "SCORE ";score(1);"x";score(2)


The result will be "SCORE 0x1". This code was supposed to increment the score for player 1, but it will increment it for player 2 instead!

Now try changing this program as follows:

  Code:
DIM score(1 TO 2) AS UBYTE
DIM player AS UBYTE

LET score(1)=0
LET score(2)=0
LET player = 1
LET score(1)=score(1)+1
PRINT "SCORE ";score(1);"x";score(2)


Now it will give the correct result "SCORE 1x0".

Tested using latest ZX BASIC release 1.4.0s1893.


Thanks, Einar!!
Will fix it ASAP!!
<<

einar

Posts: 84

Joined: Sun Apr 08, 2012 9:33 pm

Post Mon Sep 29, 2014 11:20 am

Re: Serious bug indexing arrays

boriel wrote:Thanks, Einar!!
Will fix it ASAP!!


Thank you!
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Mon Sep 29, 2014 9:40 pm

Re: Serious bug indexing arrays

Ok.

Please, download and try Version 1.4.0s1898 and tell me. :roll:
<<

einar

Posts: 84

Joined: Sun Apr 08, 2012 9:33 pm

Post Mon Sep 29, 2014 10:46 pm

Re: Serious bug indexing arrays

boriel wrote:Ok.

Please, download and try Version 1.4.0s1898 and tell me. :roll:


Problem solved, thanks a lot!!!

Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 4 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO