• 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: bug or feature?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug or feature?


  • Subject: Re: bug or feature?
  • From: Paul Berkowitz <email@hidden>
  • Date: Mon, 24 Dec 2001 12:43:38 -0800

On 12/24/01 12:21 PM, "Joe Kelly" <email@hidden> wrote:

> Paul Berkowitz hat geschreibt:
>> It might be nice if it actually canceled with an error number
>> -128, as the
>> user expects, IF the button says "Cancel" on it, perhaps. But
>> since you can
>> actually change the name of that button to say other things,
>> you need to
>> have 'false' as a way of keeping the script going to do other
>> things if the
>> user pushes that button when it says, perhaps "Help".
>>
>> So, yes, you need to trap for false.
>>
>
> When I first used "choose from list" I assumed that if the user pressed
> cancel, it would return an empty list {}. So I could do something like "if
> theChoice is not {} then". This makes perfect sense if I specify "without
> empty selection allowed" -- if I get an empty selection, no sweat, I'll
> assume the user canceled.
>
> Unfortunately, choose from list returns one of two basically un-coercible
> types: list and boolean. In theory it would be odd but acceptable (as I see
> it : ) to provide built-in coercion of class boolean and class list:
>
> {a, b, c} as boolean --> true
> {} as boolean --> false
> true as list --> {true} (as is presently implemented)
> false as list --> {} (present implementation evals to {false})

I'm not sure you've thought this through about this Cancel button taking
other names, Joe. You actually get more options with the present set-up.
'with empty selection allowed' can be a way of just passing on to other
things in a longer script, or accepting some sort of default option. But
setting 'cancel button name' to something like "Help" can give you a whole
other set of options.

set myChoice to choose from list {"Socks","A Partridge in a Pear Tree",
"Santa Claus in person"} with prompt "You get one choice only - or none"
with empty selection allowed cancel button name "Other Choices" OK button
name "My Present"

if myChoice = {} then
say "Bah humbug!"
my DoScroogeImitation()
else if myChoice is false then -- "Other Choices" button
display dialog "Greedy, aren't you?" & return & return "What was the
matter with those choices?" & return & return &"Now you get to choose
between:" & return & return & "* Two mocking birds" & return return &
"*Three mocking birds" buttons {" Cancel ", "Two", "Three"} with icon
caution
if button returned of result = " Cancel " then
say "Ha! Trick Cancel! Fooled you!"
error number -128 -- at last
else
set n to button returned of result
my FedExSend(n & " Birds")
end if

else
myFedexSend(myChoice)
end if



--
Paul Berkowitz


References: 
 >RE: bug or feature? (From: Joe Kelly <email@hidden>)

  • Prev by Date: Re: bug or feature?
  • Next by Date: Re: bug or feature?
  • Previous by thread: RE: bug or feature?
  • Next by thread: Re: bug or feature?
  • Index(es):
    • Date
    • Thread