Basics of AppleScript

tell

Script [1.4.1]:

tell application "Finder"
    -- insert actions here
end tell

Explanation: This command will tell application Finder to execute the specified commands

Script [1.4.2]:

tell application "Finder"
    empty the trash
    open the startup disk
end tell

Explanation: This Script will ask Finder to empty the trash first and then open the startup disk i.e. Macintosh HD.

Script [1.4.3]:

tell application "Finder"
    empty the trash
    beep 10
end tell

Explanation: This Script will ask Finder to empty the trash first and then beep 10 times. Beep can be used inside the the tell application command. Finder does not know anything about the beep command, but AppleScript component of Mac OS X knows about it and hence will execute it.

Script [1.4.4]:

tell application "Finder"
    empty the trash
    beep 10
end tell
open the startup disk

Explanation: Finder will empty the trash and beep 10 times. Thereafter runtime error will occur because open the startup disk command is not known to AppleScript component of Mac OS X, it is known to Finder application. An error notification will pop up in dialog.

Figure 1.4.4

Figure 1.4.4 Runtime Error