Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Serious bug indexing arrays (*solved*)
#1
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.
Reply
#2
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!!
Reply
#3
boriel Wrote:Thanks, Einar!!
Will fix it ASAP!!

Thank you!
Reply
#4
Ok.

Please, download and try Version 1.4.0s1898 and tell me. :roll:
Reply
#5
boriel Wrote:Ok.

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

Problem solved, thanks a lot!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)