Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Changing CAPITAL to Upper And Lower Case
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing CAPITAL to Upper And Lower Case

On Fri, 12 Jan 2007, Ripka, Herb wrote:

>We have a book in QuarkXPress where the titles are all CAPITAL
>letters (and in style sheet "One").

>Is there a way in AppleScript where the titles (in style sheet
>"One") can be changed to Upper And Lower Case instead?


below is a script which needs the Scripting Addition
"Satimage.osax" for changing the Caps into lower case.

The script does the job the following way:
- It loops through the stories of the front XPress project.
- For each story it makes a list of the indexes of every
  paragraph whose style sheet is "One".
- It loops through this list and changes the contents of the
  paragraphs to lower case, except the first character
  of every paragraph.

If a paragraph contains proper nouns, you must restore
the capital letters manually. The script can't do this.
It is way dumber than the chap who typed all of them capital
letters ;-). Please tell him (or her) that next time he
should type everything normally. And, if needed, set the
style of the style sheet to 'all caps'.

BTW, your subject line suggests that you'd like to convert
the text into *title case* (each word with a capital).
If this is true, then please come back.

To speed up execution, the view scale is set to 800 (trying
to avoid showing a text box. The window is reduced to a
minimal size. A script object is called to do the job.
When it has finished, the view scale and the size of the
window are restored.

To make the resizing work you must remind XPress that it
is able to do this: Before running the following script
please grab the lower right corner of the document window
and change the size a little bit. Note that this manual
action has to be done only _once_ for each "session"
with QuarkXPress.


tell application "QuarkXPress 6.52"
 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
  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
     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)
        tell characters 2 thru -1
         set contents to lowercase (it as string)
        end tell
       end try
      end tell
     end repeat
    end try
   end tell
  end repeat
 end tell
end script

Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.