Automating Adobe InDesign 2019 - AppleScript


Happy Holidays

Monday, December 16, 2019

Happy Holidays

There seems to be a lot of confusion as to what days the Twelve Days of Christmas start on--and even why there is such a thing as the Twelve Days of Christmas. Some say that the earliest Christians celebrated January 6 as the birthday of the Christ child and that it wasn't until over three hundred years later that the date was set for December 25. Whatever the reason and the season, somebody came up with a song that may have something to do with the 12 days of Yuletide which begins December 22. And for you, who want to do something silly for the Holidays, here is a script that demonstrates using repeat loops to have your Macintosh "sing" the silly song. (Experiment with the values for the voice, speaking rate, pitch, and modulation just for fun.)

Copy the script into the AppleScript editor and save it using Application as the File Format (without options checked). Make sure you have sound turned on when you double click on the file to run the script.

The Twelve Days of Christmas

set theCounters to {"First", "Second", "Third", "Fourth", "Fifth", "Sixth", ¬
"Seventh", "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth"}
set theCounted to {"a partridge in a pear tree.", "two turtle doves, and ", ¬
"three French hens, ", "four calling birds, ", "five golden rings, ", "six geese a-laying, ", ¬
"seven swans a-swimming, ", "eight maids a-milking, ", "nine ladies dancing, ", ¬
"ten lords a-leaping, ", "eleven pipers piping, ", "twelve drummers drumming, "}
set thisList to {}
set countedSoFar to ""
repeat with n from 1 to 12
	set countedSoFar to item n of theCounted & countedSoFar
	set thisPhrase to "On the " & item n of theCounters & ¬
" Day of Christmas, my true love sent to me: " & countedSoFar
	set end of thisList to thisPhrase
	say thisPhrase using "Alex" speaking rate 140 pitch 42 ¬
modulation 60 with waiting until completion
end repeat

Labeled Parameters

Notice in the above how the parameters for the say method are added following the direct parameter which defines the voice. With the exception of the direct parameter, which must directly follow the handler name, labeled parameters can appear in any order, with the labels from the handler definition identifying the parameter values. This includes parameters listed in given, with, and without clauses (of which there can be any number). With the exception of display dialog, can you think of any other methods in AppleScript which use labeled parameters?

Comments
Post has no comments.
Post a Comment
Captcha Image
Trackback Link
http://www.yourscriptdoctor.com/BlogRetrieve.aspx?BlogID=18424&PostID=1529961&A=Trackback
Trackbacks
Post has no trackbacks.

Recent Posts


Tags

rest of list automated workflow date objects text item delimiters XML tags Image Placement lists Read text file as list intent user interaction level giving up after Script panel Create Text Frame Script Library file info find change options Previous text frame Write to File import text text editbox info for Change Text Find by Attribute threaded text frames image metadata static alignment table styles CALS tables next text frame measurements convert to text import XML Placing images Duplicate stacking order Check for Styles Choose file Autoflow fit Styling Text Keyboard Shortcuts Document from Template Choose from list do script page items script folder Create Document choose file name Document stylesheets Adjust Layout XML structure integer editboxes draw from center Nested Repeat Loops grid StandardAdditions live bounds Clearing Overrides tabs primary text frame Custom Dialog time active spread coordinates move file Checkbox Control Text Style Mapping Excel Place text handlers Next Style dialog Export to PDF import styles Editbox lists of lists Repeat With sort list Library Folder place point random number reference to map tags to styles Adding Captions Chaining Paragraph Styles measurement editboxes repeat loops Multi-state objects Apply Object Style file paths bookmarks try/on error Buttons Enabling Groups dropdowns Radiobutton Group InDesign template Document Presets rest Combobox master spread Templates GREP paragraph styles entire path tab list script templates XML Image Events radiobutton control selection Character Styles object styles Find Text auto tag Script Preferences Border Panel text import preferences start paragraph

Archive