Is this a qbasic limit?
Here's the whole piece FYI. You can see what I'm trying to do. Make a list of unique random points. Started having the problem when I wrote the bit to take newly created random co-ords (x,y) and check them to see if they were unique.
Code: Select all
SCREEN 11 CLS DIM spots(2, 2000) 'init random RANDOMIZE (223) 'set 12000 random points FOR i = 1 TO 12000 x = INT(RND * 600) y = INT(RND * 440) ' search for matches match = 0 IF i > 4 THEN ' this just a mad attempt to avoid subscript out of range errors. FOR k = 1 TO i - 2 IF spots(1, k) = x THEN IF spots(2, k) = y THEN match = 1 EXIT FOR END IF END IF NEXT k END IF IF match = 1 THEN PRINT "match"; x; y i = i - 1 ELSE PSET (x, y) spots(1, i) = x spots(2, i) = y PRINT i END IF NEXT i PRINT i 'put 2000 spots in an array ' FOR i = 1 TO 2000 ' x = INT(RND * 600) ' spots(1, i) = x ' NEXT i ' FOR i = 1 TO 2000 ' y = INT(RND * 440) ' spots(2, i) = y ' NEXT i ' print out 20 from array ' FOR i = 1 TO 20 ' PRINT "Spot", i, "x", spots(1, i) ' PRINT "Spot", i, "y", spots(2, i) ' NEXT i ' match found printout ' IF match = 1 THEN ' PRINT "match found" ' PRINT spots(1, i) ' PRINT spots(2, i) ' END IF