global text pool="0123456789"
global number n=0
global rnd=0
every 1 seconds
-- set n to int(random(1)*len(pool))
-- set rnd to int(mid(pool, n, 1))
-- set pool to left(pool, n) & right(pool, len(pool)-n-1)
There are various ways we can adjust this.
The list of unique numbers can be expanded to have more than single digits. We can even generated the list with events at the start of layout to make things easier.
Another idea is to make the list reusable by adding the values back to the list. That would semi break the limit of no duplicate numbers, but maybe only allow a number to be picked again after say 50 numbers or something.
It can be fairly tedious to emulate an array with text though.
If the amount of random numbers is unbounded i'd just generate the random numbers and add them to a dictionary. If the number wasn't in it then it is unique, otherwise generate a new number. Seems simple enough, and fast at lookups. The caveat is this will use more and more memory over time.
global number rnd=0
on function "unique random"
while
-- set rnd to random(1)
---- dictionary: doesn't have key rnd
------ add key rnd to dictionary
------ stop loop
------ set return to rnd