• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: AppleScript-Users Digest, Vol 4, Issue 6
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Subject: RE: AppleScript-Users Digest, Vol 4, Issue 6
  • From: "Stockly, Ed" <email@hidden>
  • Date: Wed, 3 Jan 2007 10:40:09 -0800

>>>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:
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: AppleScript-Users Digest, Vol 4, Issue 6
      • From: deivy petrescu <email@hidden>
    • Re: Unexpected Finder window (was: AppleScript-Users Digest, Vol 4, Issue 6)
      • From: kai <email@hidden>
  • Prev by Date: Re: Mail.app "reply" verb returning nothing
  • Next by Date: Re: Mail.app "reply" verb returning nothing
  • Previous by thread: Re: LART/LRT (Was: Irritating list reply-to policy)
  • Next by thread: Re: Unexpected Finder window (was: AppleScript-Users Digest, Vol 4, Issue 6)
  • Index(es):
    • Date
    • Thread