Re: Regarding Handlers...
Re: Regarding Handlers...
- Subject: Re: Regarding Handlers...
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 18 Dec 2000 18:54:57 -0800
On 12/18/00 4:35 PM, "Robert Seckendorf" <email@hidden> wrote:
>
Question #1
>
>
Can a handler call another handler during it's execution before returning
>
to the script that called it? like in the following:
Yes, exactly like that.
>
Question #2
>
>
Is it not possible to call a handler from within an if statement...
>
I have tried the following but keep getting errors from the compiler.
>
>
display dialog "What is your favorite color?" button {"Red", "Blue",
>
"Neither"}
>
default = 1
>
set someValue to text returned from result
>
if someValue = "Red" then
>
goToRedHandler()
>
else if someValue = "Blue" then
>
goToBlueHandler()
>
end if
You must have come to AppleScript from some other programing or scripting
language.
You can't say:
default = 1
default would just be undefined here (or rather, a misuse of an AppleScript
keyword).
You've set:
set someValue to text returned from result
But there _is_ no text returned. To get text returned , you have to use the
'default answer' parameter, which you didn't put in. You put in buttons
parameter (required). So waht you have is a 'button returned', not 'text
returnmed'. And it's not 'from result', it's 'of result'.
Try this:
display dialog "What is your favorite color?" button {"Red", "Blue",
"Neither"} default button "Red"
set someValue to button returned of result
if someValue = "Red" then
goToRedHandler()
else if someValue = "Blue" then
goToBlueHandler()
end if
The syntax for 'display dialog' is in the Standard Additions scripting
addition(s) in your Scripting Additions folder. Read it in Script Editor (or
another script editor) : File -->Open Dictionary. There's more detail
available in the Scripting Additions Guide (pdf) at the Apple AppleScript
website, but it's out of date. E.g., it doesn't have the 'giving up after'
parameter of display dialog, which is in OS 9 and which you can find in the
Dictionary.
--
Paul Berkowitz