• 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: conditional error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: conditional error


  • Subject: Re: conditional error
  • From: monk <email@hidden>
  • Date: Sun, 22 Jul 2001 12:24:59 -0400

-- 7/22/01 07:56 am: email@hidden said:

>> when i run this, the first 'if' compiles fine, but the second and third give
>> me an error that 'can't make some data into expected type'
>> --
>>
>> if button returned of (display dialog "process by:" buttons {"word", "line",
>> "paragraph"} default button "word") is "word" then
>
>
>
> this bit:
>
> (display dialog "process by:" buttons {"word", "line", "paragraph"}
> default button "word")
>
> produces a record, e.g., {button returned:"word"}
>
> and when you first asked for button returned of ... you were asking
> for "button returned of {button returned:"word}. So applescript
> looked inside the record, saw that there was a "button returned" in
> the record and returned that value,ie, "word".
>
> in the remainder of the code you use the words "button returned" but
> they don't mean much to applescript. Button returned only makes sense
> to it in the previous section because there was a record which
> contained an element called "button returned".
>
> You need to store the result of the dialog in a variable where you
> can test it over time, like so:

aha! - i'm hoping to start thinking this way more and more, since that's
often a problem for me, i don't recognize when a variable is needed
>
> set chosenButton to button returned of (display dialog "process by:"
> buttons {"word", "line", "paragraph"} default button "word")
> -- chosenButton will be either "word", "line" or "paragraph"
> if chosenButton is "word" then
> -- do the word thing
> else if chosenButton is "line" then
> -- do the line thing
> else
> -- chosenButton must be paragraph
> -- do the paragraph thing
> -- what's the difference between a line and a paragraph?

well, i'm trying to distinguish between a chunk of lines (paragraph), or
single lines (sentence), is that possible do you think?

in my earlier tests reading using delimiter {space}, or delimiter {return}
seemed to give the type of results i wanted, but last night with a more
robust script i didn't notice any difference

thank you

> end if
> end if
>
>> 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
>>
>> --

h 'monk' elmer
--
//\/\\/\/\//\/\\/\/\//\/\\

http://www.assemblage.org


  • Prev by Date: Re: Making & Saving Excel documents
  • Next by Date: Re: conditional error
  • Previous by thread: Re: conditional error
  • Next by thread: Re: conditional error
  • Index(es):
    • Date
    • Thread