• 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: Quitting from an idle handler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quitting from an idle handler


  • Subject: Re: Quitting from an idle handler
  • From: Gil Dawson <email@hidden>
  • Date: Sat, 13 Aug 2005 09:39:30 -0700

At 3:15 PM -0700 8/8/05, Gil Dawson wrote:
What would you suggest?

At 7:05 PM -0400 8/8/05, Gary (Lists) wrote:
Set up your "try...on error...end try" so that it captures all of the error
data that AppleScript provides, then pass those results along to your
special-purpose error sifting handler.

At 5:02 PM -0400 8/9/05, J. Stewart wrote:
Wrap your entire script with a Try - on error block, it will catch any errors that occur within it. You can even nest other try - on error blocks within the main one if needed. The end result is a whole lot less code which means a whole lot less debugging.

Thank you for your suggestions. Let me see whether I understand them:

Below is a schematic listing of my current code. The idle routine calls several subroutines. Any of the subroutines might detect a situation that prohibits continuing, in which case they call the global FatalError subroutine, which quits the program and does not return.

on idle
   DoStep1()
   DoStep2()
   DoStep3()
   return 30
end idle

on DoStep1()
   --(code for Step1 validation)
   if AllIsWell
      --(code for Step1 production)
   else
      FatalError("Step1Msg")
   end if
   return
end DoStep1

on DoStep2()
   --(similar)
end DoStep2

on DoStep3()
   --(similar)
end DoStep3

on FatalError(msg)
   display dialog "Error:" & msg
   error number -128 -- "User Cancelled" to quit
   return  -- never executed
end FatalError


If I understand your suggestions, it would be an improvement to wrap the idle routine in a try block and change the FatalError calls to error commands:



on idle try DoStep1() DoStep2() DoStep3() return 30 on error msg display dialog "Error:" & msg error number -128 -- "User Cancelled" to quit end try end idle

on DoStep1()
   --(code for Step1 validation)
   if AllIsWell
      --(code for Step1 production)
   else
      error "Step1Msg"
   end if
   return
end DoStep1

on DoStep2()
   --(similar)
end DoStep2

on DoStep3()
   --(similar)
end DoStep3

Am I understanding your suggestions correctly?

I was initially concerned that the error command in the subroutines would not be handled by the on error block in the idle handler; however, restudying the AppleScript Language Guide convinced me that it will (5/5/99 edition, page 261, top paragraph).

I really appreciate your helping me understand this.

--Gil
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Quitting from an idle handler (From: "J. Stewart" <email@hidden>)

  • Prev by Date: Re: POSIX and lists question
  • Next by Date: Re: POSIX and lists question
  • Previous by thread: Re: Quitting from an idle handler
  • Next by thread: Re: Script application "bundles" that are read-only: error when quitting
  • Index(es):
    • Date
    • Thread