• 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: Thirteen Scripters Scripting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thirteen Scripters Scripting


  • Subject: Re: Thirteen Scripters Scripting
  • From: "Mark J. Reed" <email@hidden>
  • Date: Wed, 24 Dec 2008 18:35:32 -0500

As long as we're posting improvements to David's nice holiday script
(Thanks, David!), the text-to-speech stuff is smart enough to deal
with numerals, so since Applescript knows how to count, you don't need
to include the numbers in the lists:

set ordinals to {"st", "nd", "rd", "th"}

set giftList to {"partridge in a pear tree", "turtle doves", "French
hens", "calling birds", "gold rings", "geese a-laying", "swans
a-swimming", "maids a-milking", "ladies dancing", "lords a-leaping",
"pipers piping", "drummers drumming"}

repeat with day from 1 to count (giftList)

	set daysGifts to ""

	repeat with n from day to 1 by -1

		if length of daysGifts > 0 then
			set daysGifts to daysGifts & ", "
			if n = 1 then
				set daysGifts to daysGifts & " and "
			end if
		end if

		if n is 1 then
			set num to "a"
		else
			set num to (n as text)
		end if

		set daysGifts to daysGifts & " " & num & " " & (item n of giftList)
	end repeat

	if day > count (ordinals) then
		set suffix to the last item of ordinals
	else
		set suffix to item day of ordinals
	end if

	set nth to (day as text) & suffix

	set verse to "On the " & nth & " day of Christmas my true love sent
to me " & daysGifts

	say verse using "Alex"
end repeat
 _______________________________________________
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

  • Follow-Ups:
    • Re: Thirteen Scripters Scripting
      • From: Ed Stockly <email@hidden>
    • Re: Thirteen Scripters Scripting
      • From: Michelle Steiner <email@hidden>
    • Re: Thirteen Scripters Scripting
      • From: Doug McNutt <email@hidden>
References: 
 >Thirteen Scripters Scripting (From: David Marshall <email@hidden>)

  • Prev by Date: Re: Thirteen Scripters Scripting
  • Next by Date: Re: Thirteen Scripters Scripting
  • Previous by thread: Re: Thirteen Scripters Scripting
  • Next by thread: Re: Thirteen Scripters Scripting
  • Index(es):
    • Date
    • Thread