Just wanted to share this piece of code, it’s about the first useful thing I’ve ever written in AppleScript.
It’s a short script designed to pick two random words from a text file (I use a dictionary word list) and display them together. I designed it because I want to register a domain name that’s easy to remember, and slightly oddball:
set loopstop to "0" -- We'll use this to break the dialog box cycle
tell application "TextEdit"
activate
tell document "words.txt" -- name of file, must have it open in textedit
activate
repeat while loopstop = "0"
set maxnum to the number of words of it -- sets maximum range for number generator
set randnum1 to random number from 1 to maxnum
set randnum2 to random number from 1 to maxnum
set firstword to word randnum1 of it -- first word
set secondword to word randnum2 of it -- second word
display dialog firstword & " " & secondword buttons {"Again", "Done"} default button 1
set the user_choice to the button returned of the result
if the user_choice is "Done" then set loopstop to "1" -- break the loop
end repeat
end tell
end tell
The next step - which I’d appreciate some help with, since I’m very new to this - is to iterate this loop (say) 100 times and write the results to another text file, so I can pick the best names en masse. Suggestions and comments much appreciated.
Cheers,
Flashman
http://blastradius.blogspot.com