• 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
Application responses, Timeouts, Try statements, Activate - how do they really work?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Application responses, Timeouts, Try statements, Activate - how do they really work?


  • Subject: Application responses, Timeouts, Try statements, Activate - how do they really work?
  • From: Richard Rönnbäck <email@hidden>
  • Date: Tue, 11 Dec 2007 08:01:13 +0100
  • Thread-topic: Application responses, Timeouts, Try statements, Activate - how do they really work?

Title: Application responses, Timeouts, Try statements, Activate - how do they really work?
I have some questions about how some things in the AppleScript world fit together, specifically I wonder about:

* Activate
* With timeout statements
* Try statements
* Ignoring application responses

The background is that FileMaker Pro is automated to run a sequence of internal and external scripts in what's basically an endless loop. A number of other process running on the same machine, and other machines will however occasionally need to access FileMaker (through AppleScript) so the whole loop is controlled by an AppleScript stay open application with an idle statement, where in the idle period these other process can get through. Finally the idle app must be able to run unattended, yet allow users to break out of the loop, in a controlled way, when all tasks in the loop are completed and before a new loop is entered.

So, I started out simple

on idle
        set
myGaveUp to  false
       try
           activate
           set myGaveUp to gave up of (display dialog "some text" giving up after 5)
        end try
   
    --the useful stuff goes here
   return 5
end idle

But for reasons unknown to me, the activate command will from time to time fail to activate the applet, which will then not display dialog, which causes the script to halt until a user manually activates the applet, or worse, lead to an AppleEvent time out error, which will break the script completely

So, I then tried to work around the problem with the dialog not displaying with various combinations of "with timeout" statements etc, which all failed,

In the end the only thing I could come up with that would successfully display the dialog (when activate works) and continue the script (when activate doesn't work) was this:

on idle
   set myGaveUp to false
   
    ignoring application responses
       try
           activate
           set myGaveUp to gave up of (display dialog "Some text" giving up after 5)
        end try
   end ignoring
   
    --the useful stuff goes here
   return 5
end idle

However, if the activate command fails, so that the dialog does not display, the "giving up after 5" part has no meaning. Nor does timeout  a statement seem to do anything at all in these cases, so AppleScript seem to return to it's default timeout, so even though the script will eventually continue, it does so after a longer period than I would want.

So, my questions are these:

* What can cause the activate command not to work?
* Why is "Display dialog" dependent on the app being activated (I can see why it seems pointless, but why would it from a technical standpoint be dependent on the app being active)
* Why does not a simple "Try statement" allow the continuation of the process, if the dialog cannot display
* Why has "timeout statements" sometime no effect
* Why does "ignoring application responses" allow the script to continue, but not the try statement?

 _______________________________________________
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

  • Follow-Ups:
    • Re: Application responses, Timeouts, Try statements, Activate - how do they really work?
      • From: Philip Aker <email@hidden>
  • Prev by Date: Re: dev tools
  • Next by Date: Re: Application responses, Timeouts, Try statements, Activate - how do they really work?
  • Previous by thread: Re: Welcome back, Dave!
  • Next by thread: Re: Application responses, Timeouts, Try statements, Activate - how do they really work?
  • Index(es):
    • Date
    • Thread