Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: AppleScript-Users Digest, Vol 4, Issue 6



>>>deivy>>>I honestly feel that:
>>>"tell application "Finder" to if exists window 1 then tell window 1  to close"

>>>is not just English like but it is sooo much colloquial like that I  can't believe it works!

>>>As an example here is an interchange I could have with my kids:

>>>Tell offspring "Older Son" to if the lights in his room are on then  
>>>tell offspring "Younger Son" to turn them off.

>>>I hate analogies...  :)

Wow, what a great analogy. And it illustrates another example of how AppleScript can be even more English-like (at least at my house with my teenagers)

You see if I run this script on my mac, when there is NO Finder window open...

tell application "Finder"
	activate
	tell Finder window 1 to if exists then
		set current view to list view
		--do other stuff
	end if
end tell


Then the script actually opens a new window, but doesn't execute any of the other commands within the freaky tell/if block.

Which, by your analogy would be like telling your son to turn off the light in his room if it's on, and having him turn it on but not telling the younger son to turn them off, which is not the intended result.

As I said before that's a pretty nifty construct, but I'm not sure how reliable it is and I certainly wouldn't recommend it for ordinary AppleScripters.

ES
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.