Basics of AppleScript


Script [5.2.1]: display dialog "Hello World"

Explanation: It will display a dialog with text Hello World. It is similar to javascript pop up in web browsers.

Figure 5.2.1

Figure 5.2.1 Displays a Dialog

Script [5.2.2]:

set hello to "Hello World"
display dialog "hello"
display dialog hello

Explanation: This will create a variable hello with text Hello World. A dialog will be displayed with text hello and not the text of variable hello.

This is because we have mentioned the text in double quotes. If we want Hello World to be printed in dialog, then we need to mention the variable name without double quotes or Hello World in double quotes.

The third line will print contents of hello variable in the dialog.

Figure 5.2.2

Figure 5.2.2

Figure 5.2.2 Strings in Dialog