Re: conditional error
Re: conditional error
- Subject: Re: conditional error
- From: JollyRoger <email@hidden>
- Date: Sun, 22 Jul 2001 12:39:28 -0500
On 7/22/2001 3:50 AM, "monk" <email@hidden> wrote:
>
if button returned of (display dialog "process by:" buttons {"word", "line",
>
"paragraph"} default button "word") is "word" then
>
>
set _listsource to (read _source as text using delimiter {return,
>
space})
>
>
else if button returned is "line" then
>
>
set _listsource to (read _source as text using delimiter {return})
>
>
else
>
>
set _listsource to (read _source as text using delimiter {space})
>
>
end if
Study the Standard Additions dictionary more thoroughly.
---
display dialog : Display a dialog box, optionally requesting user input
display dialog string -- the text to display in dialog box
[default answer string] -- the default editable text
[buttons list] -- a list of up to three button names
[default button number or string] -- the name or number of the
default button
[with icon number or string] -- the name or ID of the icon to
display
[with icon stop/note/caution] --
or one of these system icons
[giving up after integer] -- number of seconds to wait before
automatically dismissing dialog
Result : dialog reply -- a record containing the button clicked and text
entered (if any)
say : Speak the given text
say anything -- the text to speak, which can include intonation
characters
[displaying string] -- the text to display in the feedback window
(if different). Ignored unless Speech Recognition is on.
[using string] -- the voice to speak with
[waiting until completion boolean] -- wait for speech to complete
before returning (default is true). Ignored unless Speech Recognition is on.
Class dialog reply : Reply record for display dialog command
Properties:
button returned string [r/o] -- name of button chosen (empty if giving
up after9 was supplied and dialog timed out)
text returned string [r/o] -- text entered (present only if default
answer9 was supplied)
gave up boolean [r/o] -- did the dialog time out? (present only if
giving up after9 was supplied)
---
As you can see, "display dialog" returns a "dialog reply" for the result.
"dialog reply" is defined as a record containing three properties: button
returned, text returned, and gave up. In your second and third "else if"
clauses, you are not getting the "button returned" property from the
"display dialog" result, so of course you are getting an error. Instead,
store the "display dialog" result in a variable like so:
set myResult to display dialog ...
Then you can get the value like this:
else if button returned of myResult is "line" then
Or this:
set myButton to button returned of myResult
if myButton is "word" then
.
.
else if myButton is "line" then
.
.
(etc.)
HTH
JR