Inspired by Thomas's dictionary suggestion, the following code checks for duplicates against the array as the array is being filled.
O.K. with Pelles and MSVC.
DIM ArrayElements, ArrayLocation, UniQCount, Int1
DIM AlphaBits$[10000]
DIM TheBit$
TheBit$ = CHR$(RND2(65, 90))
AlphaBits$[0] = TheBit$
FOR INTEGER i = 1 TO 9999
TheBit$ = CHR$(RND2(65, 90))
FOR INTEGER ii = 0 TO ArrayLocation
IF TheBit$ = AlphaBits$[ii] THEN
GOTO Jump1
END IF
NEXT ii
ArrayLocation++
AlphaBits$[ArrayLocation] = TheBit$
Jump1:
NEXT i
?
ArrayLocation++
PRINT " Of the 10000 elements generated, ", _
ArrayLocation, " are unique and were inserted in the array."
?
Int1 = ArrayLocation - 1
PRINT " The UniQ elements are : ";
FOR INTEGER i = 0 TO Int1 - 1
PRINT $AlphaBits[i], ", ";
NEXT i
PRINT $AlphaBits[Int1]
?
QSORT AlphaBits$, ArrayLocation
PRINT " which, when sorted, are : ";
FOR INTEGER i = 0 TO Int1 - 1
PRINT $AlphaBits[i], ", ";
NEXT i
PRINT $AlphaBits[Int1]
?
END