|
I couldn't find an example showing how to display a list of strings using AppleScript, so I created the following simple example. First I create a list (in this case a short list of voices on Mac OS/X that can be used with the say command), and then I display the list in a dialog the user can use to select one of the items in the list.
--
-- a sample AppleScript program to prompt a user to select an item from a list
--
-- display a dialog to prompt the user to select a voice from a list of voices
set myVoices to {"Agnes", "Kathy",
"Princess", "Vicki", "Victoria"}
-- get the voice the user selected from the list
set selectedVoice to {choose from list myVoices}
-- say "Hello world" using the voice the user selected
say "Hello world" using selectedVoice
Here's what the dialog looks like:
At the moment I'm new to AppleScript, but I personally don't like using syntax like this:
display dialog "What should I say?" default answer ""
to display a dialog prompting a user to enter some text, and significantly different syntax like this:
choose from list myVoices
to display a dialog prompting the user to select an item from a list. I know that the intent is to make the language very human-readable, but I'd prefer more consistency here.
|