On Apr 23, 2009, at 1:49 PM, Tobias Exner wrote: what's the meaning of the following line? set selectedItem to (original item of selectedItem) as alias
An alias file (has a little arrow at the lower left of the icon) points to a file somewhere on your Mac.
tell application "Finder" set selectionList to the selection as alias list if (count items of selectionList) ≠ 1 then beep return end if set selectedItem to (item 1 of selectionList) if (class of item selectedItem) is alias file then set selectedItem to (original item of selectedItem) as alias end if if (class of item selectedItem) is not folder then beep return end if -- -- selectedItem is now an alias to a folder -- do stuff with it here end tell
If you have selected a single alias file that points to a folder, then you probably intend that that folder be used in the script. The line that tests if you have selected an alias file replaces 'selectedItem' (an alias (pointer) to an alias file) with (an alias (pointer) to the item to which the alias file points). The item pointed to by an alias file is known in Finder as the 'original item'. It's in the Finder's dictionary.
If you want to use a "Drag & Drop" interface, instead of a "Select & Launch" interface, then your script will also have an open handler that begins ...
on open dropList
'dropList' should behave like 'selectionList' in the script above ... but it does not! 'dropList' is a list of aliases and never contains an alias (pointer) to an alias file, because alias files are automatically resolved to the 'original item'.
|