I don't understand ... [ 2 of 2 ]

I’m just learning applescript. I’m a professional programmer (C++/Python/Lisp/i86 assembly) but I’m having real trouble getting to grip with applescript’s syntax.

I have two questions, I’ll ask one in this thread and start a new thread for the other.

Basically, I have trouble understanding the help (.sdef) presented for various items.

A case in point is this from iPhoto 6:

All commands seem to be of the form do something reference param argument in the help but I can never work out how to specify ‘reference’ or what it means. In this instance the reference need not be specified.

Thanks,
Brian.

Hi, Brian.

Everyone finds AppleScript dictionaries difficult at first, so don’t feel you’re being particularly dense. :slight_smile: It’s also the case that dictionaries are occasionally incomplete or inaccurate. But you get a feel for them after a while and they give you somewhere to start experimenting.

Unfortunately, I don’t use iPhoto and don’t understand what one might do with assign keyword. But what the dictionary entry’s basically saying is:

It’s a two-word verb (or command) that does what’s described.

The command is followed by a direct parameter in the form of a reference. In this case, the reference will be to something in iPhoto. A reference in AppleScript is a description of something in relation to something else, rather than an actual value. It usually contains or implies an ‘of’. For example, ‘item 1 of myList’, ‘file “Fred.txt” of folder “Bert”’, ‘selection’ (of application “iPhoto”), etc.

The command and reference are immediately followed by a non-optional labelled parameter called string, which should in turn be followed by some Unicode text. Every app I know that specifies Unicode text parameters also accepts strings, so you may not need be fussy about this.

Hope that helps a little…

Edit: Corrected a couple of gibberish typos. :rolleyes:

FYI, you can effectively check “Keyword” boxes: http://files.macscripter.net/bbs/images/iphoto_keywords_21255.png

The oddity here is that you don’t specify a reference. I believe the listing says ‘reference’ because that’s how the actual dictionary has it labeled; However, for this specific command, the reference (to the “currently-selected photos”) is likely hardcoded.

Like Nigel said, a ‘reference’ is basically a reference to any object.

Objects vary by application; In iPhoto, you have photos and albums; In iTunes, you have tracks and playlists.

Thanks for that information, Bruce. No wonder Brian was confused about the reference parameter! :expressionless:

Thanks guys.

Yes, the issue to me was that not only do you not need a reference in this instance but it seems to be impossible to provide one. Luckily, the default, which is the current selection, works for my situation.

Thanks,
Brian.