• 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: Tell Blocks Considered Harmful (was Re: open for access)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tell Blocks Considered Harmful (was Re: open for access)


  • Subject: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • From: Chris Page <email@hidden>
  • Date: Tue, 16 Dec 2008 16:05:37 -0800

On Dec 16, 2008, at 15:04 PM, Chris Page wrote:

Which actually brings to mind another reason it's better to include osax calls in a tell.

Tell application "Quark"
tell document 1
set myText to contents of text box 1
display dialog xxxx

....

Once I've started the document tell block, my script is addressing that document, even if another document becomes document 1, for as long as I stay inside that tell.

Notice that, for someone not well-versed with AppleScript -- and even some who are -- that script literally says "tell document 1 to display dialog". What does that mean? The document isn't displaying the dialog, the application is. By unnecessarily placing commands inside tell blocks, the script becomes misleading about what it actually means and what it intends to mean.

Come to think of it, this is a perfect example of why placing ‘display dialog’ inside ‘tell document 1’ is a bad idea.


Mac OS X has something called “sheets”. These are the dialogs that are attached to other windows, that slide down from the window title bar. They are “document modal” -- they prevent the user from interacting with the contents of a document window until they dismiss the sheet. They're generally better than “application modal” dialogs, which prevent user interaction with the entire application.

It would probably be useful to add support for sheets, and a fairly natural way to do that without introducing new terminology is to make

  tell document 1 to display alert ...

present a sheet attached to the document window.

But that would change the behavior of your example script, possibly in a way that effectively breaks the script.

But as the developer of ‘display dialog’ it's difficult for me to say, just seeing the source to your script. I don't know whether you intended to display an application-modal dialog or if your purposes only require a document-modal dialog.

If you instead kept ‘display dialog’ outside the ‘tell document 1’ block, it would be clear to me that you intended to make that dialog application-modal, and I would know for certain that changing the behavior of ‘tell document 1 to display dialog’ wouldn't break your script.

In addition, as another script writer, if I inherited your script and I saw that sheets were now supported, since your script was written, I wouldn't be able to tell whether the script is okay with the new behavior or not. I wouldn't know whether I need to change it to send the ‘display dialog’ command to the application specifically to get an application-modal dialog instead of a sheet.

--
Chris Page - AppleScripter

 The other, other AppleScript Chris



_______________________________________________
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/archives/applescript-users

This email sent to email@hidden
References: 
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Shane Stanley <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Ed Stockly <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Ed Stockly <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)

  • Prev by Date: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Next by Date: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Previous by thread: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Next by thread: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Index(es):
    • Date
    • Thread