Pages

Friday, June 4, 2010

AppleScript. Hello, World!

You can find AppleScript Editor in the folder Utilities of Applications:

Type "Hello":

Press Compile and then Run - see "Hello" in the result window:

Let's "complicate" the script. Type:

display alert "Hello"

Press Compile and Run. You see a simple alert with one Ok button on the screen:


Let's make an application from it. In the File menu select "Save as". You will see this save dialog:


Select "Application" in the File Format combo box. Set a name, for example Hello. Set a path - I set the desktop:

Now on the desktop I see my Hello application. When I click on it, I see my alert:
In the end of this post I'd like to show a less useless and a bit funny example. You can use AppleScript editor as a calculator. Simply type something you need to calculate, compile and run it:
Of course you can arrange it as a script:


display alert 45 + 16 * 2 / 3



This book below contains a nice section about AppleScript:

No comments:

Post a Comment