• 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: returning math answers given a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: returning math answers given a string


  • Subject: Re: returning math answers given a string
  • From: Kai <email@hidden>
  • Date: Mon, 27 Jan 2003 13:30:04 +0000

on 27/1/03 11:41 am, some klutz wrote:

> to getQuestion()
> set {tid, q, m} to {text item delimiters, "", "Ask me a math question:"}
> repeat
> set q to (display dialog m default answer q with icon 1)'s text returned
> set {k, a} to (getAnswer to q)
> set m to k & " = " & a & return & return & "Ask me another math question:"
> end repeat
> set text item delimiters to tid
> end getQuestion

[Sigh...] This overlooks the fact that the TIDs won't ever get reset.
(Shouldn't pose a problem when the script is saved and run as an app - but
could cause unexpected results when run from Script Editor.)

In addition, while I didn't really intend to trap specific errors, leaving
the dialog's entry box empty would result in a fairly basic one.

So... something like this should fix'em:

================

to getQuestion()
set {tid, q, m} to {text item delimiters, "", "Ask me a math question:"}
repeat
set {q, b} to (display dialog m default answer q [NO BREAK]
buttons {" Cancel ", "OK"} default button 2 with icon 1)'s [NO BREAK]
{text returned, button returned}
if q is "" or b is " Cancel " then exit repeat
set {k, a} to (getAnswer to q)
set m to k & " = " & a & return & return & "Ask me another math question:"
end repeat
set text item delimiters to tid
end getQuestion

================

--
Kai (who is now seriously considering a brain transplant)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: returning math answers given a string (From: Kai <email@hidden>)

  • Prev by Date: Re: Getting the names of all applications
  • Next by Date: Re: Creating a list of alias from folder contents
  • Previous by thread: Re: returning math answers given a string
  • Next by thread: Forcing a script to open in Classic
  • Index(es):
    • Date
    • Thread