tell Finder window 1 if exists (was something else)
tell Finder window 1 if exists (was something else)
- Subject: tell Finder window 1 if exists (was something else)
- From: "Stockly, Ed" <email@hidden>
- Date: Tue, 2 Jan 2007 12:53:35 -0800
>>Bryan>>How in the devil am I supposed to parse the line below which reads " tell Finder window 1 to if exists then".
>>>I don't get this at all (although, of course, I can figure out what it means, it seems to me totally ungrammatical.
Bryan, you need to relax a bit. Obviously, you are able to "parse the line" and you do "get this" so it seems as if you are looking for something to complain about. (On the other hand, since you're actually talking about AppleScript on the AppleScript list and not Shell scripting or mailing list behavior, I thank you.)
Anyway, AppleScript is not English, but, it is "English-like" and, as with English, not everyone who uses the language uses it in a way that is easy for others to understand.
Also, as with English, some of AppleScript's syntax rules are (to echo an earlier message) more like guidelines than actual rules. And, as with English, some of AppleScript's syntax and grammatical structure evolved in ways that are not exactly logical.
In the example you asked about:
First, the line was included within a "Finder" tell block, and commands within that block are directed to the finder. The line itself refers to a "Finder window" which is an object class of the finder which refers specifically to windows for viewing files, as opposed to other types of finder windows.
Next, the script creates very odd construct combining a "tell Finder window 1" with if/then. Most ordinary AppleScripters write these constructs separately:
tell finder window 1
if it exists then
--commands here
end if
end tell
But the example you asked about was not written by an "ordinary" AppleScripter and creates a freaky tell/if/then block, and all the commands with the tell/if block are directed to the specified finder window only if it exists and are not executed if the finder window does not exist.
Which is all pretty nifty, although not terribly intuitive and I'm not sure how reliable it is outside this context, so I wouldn't recommend it for new AppleScripters.
>>>I'd be grateful for any further enlightenment.
Hope that's somewhat enlightening.
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden