a demonstration of random numbers and random letters – note “some”
set x to {}
repeat (random number from 8 to 10) times
set end of x to some item of "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
end repeat
x as text --> "JUEQPJBH", "LFOBPXHJI", "TQRVYJPHFA"
a demonstration of random numbers and random letters – note “some”
set x to {}
repeat (random number from 8 to 10) times
set end of x to some item of "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
end repeat
x as text --> "JUEQPJBH", "LFOBPXHJI", "TQRVYJPHFA"
3 replies on “Random in Applescript”
i altered it slightly so that:
repeat 500 times
set x to {}
repeat (random number from 3 to 10) times
set end of x to some item of “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
end repeat
display dialog x as string
end repeat
will eventually yield a 3 to 10 letter word.
stop the script at any time by hitting cancel
how do you get it to show the new random letters in dialog box
It took some digging but I figured it out.
set x to {}
set end of x to some item of “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
say x
display dialog x
you can even do whole words
set x to {}
set end of x to some word of “Hi hello”
say x
display dialog x
see if that works 🙂