RE: AppleScript-Users Digest, Vol 4, Issue 6
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