zxbasic
zxbasic copied to clipboard
FOR LOOP repeating
I find this for loop repeats, only happens if to is set to 255
for x = 0 to 255
print at 0,0;x
pause 1
next x
pause 0
That's to be expected if x is of type UByte.
By default, if you don't DIM x it will assign the shortest / narrowest type (UByte in this case).
FOR loops like the above means the loop must enter when x = 255, and stop when x = 256. Since x is of type UByte, it will never reach 256. Hence the infinite loop.
EDIT: I repost my comment because the previous response has been lost :(
Sorry ignore my last post on this.