Re: Changing CAPITAL to Upper And Lower Case
Re: Changing CAPITAL to Upper And Lower Case
- Subject: Re: Changing CAPITAL to Upper And Lower Case
- From: Hans Haesler <email@hidden>
- Date: Tue, 16 Jan 2007 23:40:40 +0100
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 6.52"
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 6.52"
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