RE: AppleScript-Users Digest, Vol 4, Issue 31
RE: AppleScript-Users Digest, Vol 4, Issue 31
- Subject: RE: AppleScript-Users Digest, Vol 4, Issue 31
- From: "Ripka, Herb" <email@hidden>
- Date: Sat, 17 Feb 2007 14:53:29 -0600
- Thread-topic: AppleScript-Users Digest, Vol 4, Issue 31
Thanks to Hans, and to Tim Mansour, for the answer to this problem. Also thanks to kai, Adam and others for their help too.
Sorry for the delay in responding, but the editor had some delays in finally getting the files to me.
--Herb Ripka
Greendale, WI
> ----------
> From: applescript-users-bounces+hripka=email@hidden on behalf of email@hidden
> Reply To: email@hidden
> Sent: Tuesday, January 16, 2007 6:53 PM
> To: email@hidden
> Subject: AppleScript-Users Digest, Vol 4, Issue 31
>
> Date: Tue, 16 Jan 2007 23:40:40 +0100
> From: Hans Haesler <email@hidden>
> Subject: Re: Changing CAPITAL to Upper And Lower Case
> To: <email@hidden>
> Message-ID: <l03130300c1d3039117ce@[162.21.180.1]>
> Content-Type: text/plain; charset="us-ascii"
>
> On Mon, 15 Jan 2007, Ripka, Herb wrote:
>
> >Yes, the text in the style sheet should be changed so that
> >every word is capitalized.
> >
> >Minor changes like "and", "or", etc. can be proofread and fixed
> >(to be lowercase) by hand.
>
> Herbert,
>
> the following script needs "TextCommands.app" (as recommended
> recently by Tim Mansour). The first half of the code is unchanged.
> There is a slight change in the script object and a new handler.
> ---
> tell application "QuarkXPress"
> activate
> if (document 1 exists) then
> tell document 1
> set projName to name
> set actView to view scale
> set view scale to 800
> end tell
> tell project 1
> tell active layout space
> set layName to name
> end tell
> end tell
> set winName to projName & " : " & layName
> tell window winName
> set {wx1, wy1, wx2, wy2} to bounds
> set bounds to {wy1, wx1, 23, 23}
> end tell
> with timeout of 300 seconds
> do script {toLower}
> end timeout
> tell document 1
> set view scale to actView
> end tell
> tell window winName
> set bounds to {wy1, wx1, wy2, wx2}
> end tell
> display dialog "Done." buttons "OK" default button 1 with icon 1 giving up after 1
> else
> display dialog "Open a document, please." buttons "OK" default button 1 with icon 2
> end if
> end tell
>
> script toLower
> global indexList
> tell document 1 of application "QuarkXPress"
> set selection to null
> repeat with i from 1 to count of stories
> tell story i
> try
> set indexList to (index of every paragraph whose name of style sheet is "one")
> repeat with j from 1 to count of indexList
> tell paragraph (item j of my indexList)
> try
> set contents to my tCase(it as string)
> end try
> end tell
> end repeat
> end try
> end tell
> end repeat
> end tell
> end script
>
> on tCase(aString)
> tell application "TextCommands"
> set defString to titlecase aString
> end tell
> return defString
> end tCase
> ---
>
> Maybe you'd like to use a list with exceptions in order
> to reduce manual labor. Then, please, replace the 'tCase' handler
> with the following code. Note: The list is just a suggestion,
> to be edited and completed ...
> ---
> property exceptList : {"a", "all", "an", "and", "at", "be", "if", "in", "is", "of", "or", "on", "my", "so", "to", "the"}
>
> on tCase(aString)
> set wordList to {}
> set AppleScript's text item delimiters to " "
> set aList to text items of aString
> set nItems to count aList
> tell application "TextCommands"
> set end of wordList to titlecase item 1 of aList
> repeat with i from 2 to nItems - 1
> set curWord to item i of aList
> if curWord is not in exceptList then
> set curWord to titlecase curWord
> else
> set curWord to lowercase curWord
> end if
> set end of wordList to curWord
> end repeat
> set end of wordList to titlecase item -1 of aList
> end tell
> set defString to (every text item of wordList) as string
> set AppleScript's text item delimiters to > {""}
> return defString
> end tCase
>
> ---
> Regards,
> Hans
>
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden