I have worked with a couple of scripting languages before and am just reading up on Apple script at the moment but I am having a little trouble grasping the syntax from the dictionary. Firstly it looks like the documentation built into Tiger is out of date because it keeps referencing to blue text in the syntax (but its all back in my dictionary) (I think its left over from 10.3). Anyways… In the first lot of examples I have been going through I the have been telling me to use the following in a script
tell application “Finder”
close the front window
end tell
Now if I go into the finder dictionary I would assume I would be able to look up the window object and see all the functions that associate with it. The only place I find the command close is in the Standard Suite along with other commands. How do I know what commands are applicable to which objects? Also I cant see any reference in the dictionary to term Front or Front Window.
I dont know if these are stupid questions but I just want to be self sufficient and none of the tutorials seem to explain how to what is being writen interacts with the dictionary.
Thanks
WhiteTail:
Yeah, the dictionary is a crummy place to begin, in my opinion. Nice reference for later on, once you have some the syntax under control.
A better place to begin may be some of the sites in the Tutorial/Instructional sites found on our links page:
http://macscripter.net/links/
Good luck,
Thanks very much. I will do that. At least I’m not going crazy.
Hi, WhiteTail.
Besides what Craig said, you should also ignore other people’s references to particular text colours in AppleScript source code or dictionaries. The colours and text styles for the various kinds of AppleScript keywords are a user preference, which can be set in Script Editor’s Preferences. If someone sends you a script compiled on their computer with their preferences, the text will be formatted according to your own preferences when you open it in Script Editor on your own machine. In recent years, Apple has started off new AppleScript installations with a default set of colours (it used to be black), but there are no official ones. It’s entirely your own choice.
The idea of the formatting is to make it easier to see at a glance what sort of words you’re using in your scripts. (Or, at least, what the compiler thinks they are.) People often think it’s a cool idea to post code snippets formatted according to their own preferences. But this isn’t much help when others are used to completely different colours and styles. In public, it’s best to use a single, preferably dark colour.
you might want to download AppleScript For Absolute Starters, a free ebook which will teach you the basic syntax and stuff, it was written for jaguar, but is pretty much up-to-date. highly recommended. 