AppleScript - Hello, World!

In AppleScript, the traditional Hello, world! program could be written in many of different forms:

display dialog "Hello, world!" -- a modal window with "Ok" and "Cancel" buttons (you can customize the buttons) -- or display alert "Hello, world!" -- a modal window with a single "Ok" button -- or say "Hello, world!" -- an audio message using a synthesized computer voice

AppleScript has several user interface options, including dialogs, alerts, and list of choices.

-- Dialog set dialogReply to display dialog ¬ "Dialog Text" default answer ¬ "Text Answer" hidden answer false ¬ buttons {"Skip", "Okay", "Cancel"} ¬ default button ¬ "Okay" cancel button ¬ "Skip" with title ¬ "Dialog Window Title" with icon note ¬ giving up after 20 --Choose from list set chosenListItem to choose from list {"A", "B", "3"} ¬ with title "List Title" ¬ with prompt "Prompt Text" ¬ default items "B" ¬ OK button name "Looks Good!" ¬ cancel button name "Nope, try again" ¬ multiple selections allowed false ¬ with empty selection allowed --Alert set resultAlertReply to display alert ¬ "Alert Text" as warning ¬ buttons {"Skip", "Okay", "Cancel"} ¬ default button 2 ¬ cancel button 1 ¬ giving up after 2

Each user interaction method can return the values of buttons clicked, items chosen or text entered for further processing.

For example:

display alert "Hello, world!" buttons {"Rudely decline", "Happily accept"} set theAnswer to button returned of the result if theAnswer is "Happily accept" then beep 5 else say "Piffle!" end if

Read more about this topic:  AppleScript