• 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: How can I simplify the math in this script?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I simplify the math in this script?


  • Subject: Re: How can I simplify the math in this script?
  • From: Skeeve <email@hidden>
  • Date: Tue, 17 Jun 2008 15:17:04 +0200

What about skipping the counter and adding a plural-s?

property Launch3G : date "Friday, July 11, 2008 6:00:00 PM"

set units to {{weeks, "week"}, {days, "day"}, {hours, "hour"}, {minutes, "minute"}, {1, "second"}}

repeat
set timeLeft to Launch3G - (current date)
set resultString to ""
repeat with unittuple in units
set unitSize to item 1 of unittuple
set unitName to item 2 of unittuple
set unitCount to timeLeft div unitSize
set timeLeft to timeLeft mod unitSize
if resultString is "" then
set resultString to "iPhone 3G will be launched in exactly"
else
set resultString to resultString & ","
end if
set resultString to resultString & " " & unitCount & " " & plural(unitName, unitCount)
end repeat
display dialog (resultString & ".") giving up after 1
end repeat


to plural(some_text, is_plural)
   if is_plural = 1 then return some_text
   return some_text & "s"
end plural
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >How can I simplify the math in this script? (From: Michelle Steiner <email@hidden>)
 >Re: How can I simplify the math in this script? (From: Jeff Porten <email@hidden>)
 >Re: How can I simplify the math in this script? (From: Michelle Steiner <email@hidden>)
 >Re: How can I simplify the math in this script? (From: Jeff Porten <email@hidden>)
 >Re: How can I simplify the math in this script? (From: "Mark J. Reed" <email@hidden>)
 >Re: How can I simplify the math in this script? (From: Michelle Steiner <email@hidden>)
 >Re: How can I simplify the math in this script? (From: "Mark J. Reed" <email@hidden>)
 >Re: How can I simplify the math in this script? (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: How can I simplify the math in this script?
  • Next by Date: Will this work?
  • Previous by thread: Re: How can I simplify the math in this script?
  • Next by thread: Re: How can I simplify the math in this script?
  • Index(es):
    • Date
    • Thread