• 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: newbie: how to get result of "cancel"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie: how to get result of "cancel"


  • Subject: Re: newbie: how to get result of "cancel"
  • From: Cal <email@hidden>
  • Date: Tue, 23 Jan 2001 23:24:05 -0500

Bret Linford <email@hidden> wrote:

I know that if I do a "choose folder" and the user hits "cancel" that the
script will be killed. How do I get the "result" of a "cancel"? If the user
hits "cancel", I would like to have a dialog box that says something like
"Installation aborted". Thanks!

Michelle Steiner <email@hidden> replied:

try
set x to choose folder
--do something with x
on error
display dialog "Installation aborted"
end try

There may be other errors than the user cancelling, so you might want to
trap for other errors.

Yes. As an explanation, when a user hits the "Cancel" button (or types Command-period during script execution), the currently executing command produces the user cancelled error, numbered -128. As Michelle pointed out, there may be other errors. You can make the error handler specific to the cancelling situation:

try
set x to choose folder
--do something with x
on error number -128
display dialog "Installation aborted"
end try

This way, if it's an error other than cancelling, then the script will fail as it should.

Cal


  • Follow-Ups:
    • Re: newbie: how to get result of "cancel"
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: whose name contains space
  • Next by Date: Mounting Xinet Volume via TCP/IP
  • Previous by thread: Re: newbie: how to get result of "cancel"
  • Next by thread: Re: newbie: how to get result of "cancel"
  • Index(es):
    • Date
    • Thread