Random in Applescript

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 to “Random in Applescript”

  1. 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

    1. 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 🙂

Comments are closed.