Re: Repeat-Dialog-Error
Re: Repeat-Dialog-Error
- Subject: Re: Repeat-Dialog-Error
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 28 Feb 2001 23:30:19 -0800
On 2/28/01 10:23 PM, "Daniel Shockley" <email@hidden> wrote:
>
Paul made some good points about how the "Cancel" button genereating an actual
>
error is a good
>
thing. Nevertheless, if you want a Cancel button that just acts like a regular
>
old button, name it
>
" Cancel " Notice the spaces on each end of the name? AppleScript generates
>
the "User Cancelled
>
error when a button named "Cancel" is clicked and released, but " Cancel " is
>
just another button
>
with a text name.
That is especially useful on an English-language system when you need to do
something, like restore some property to how it started out (as the user
would expect when he cancels) _before_ the real cancel:
property theBeeps : 0
display dialog "How many beeps would you like to hear every time this
script finishes running?" buttons {"0", "1", "100"} with icon 1
set theBeeps to (button returned of result) as integer
display dialog "" & theBeeps & " beeps? Are you sure about that?"
buttons {" Cancel ", " Yes! "} with icon 2
if button returned of result = " Cancel " then
set theBeeps to 0 -- YOU'D BETTER DO THIS
error number -128 -- now you can cancel
end if
-- do stuff
beep theBeeps -- or else you're going to get 100 beeps
--
Paul Berkowitz