Article View: adobe.scripting.indesign
Article #20681Re: Change case of selected text? (AS)
From: Carl Davaz
Date: Wed, 03 Jul 2002 15:00
Date: Wed, 03 Jul 2002 15:00
51 lines
2997 bytes
2997 bytes
Aaron, Now I think I understand that you need a combination of what Dave and I were saying. If you typed "PAHO" in all upper case letters to begin with, while the script does change your text to small caps, you can't see the change because of how you typed the word. If you typed it "paho" and used the user interface to change it to all caps, the script to change it to small caps would have worked and you would have seen the change. The first thing your script needs to do is change the upper case PAHO to paho, then apply the small caps case (capitalization). Select the word to be changed in the ID document and try running the script below: tell application "InDesign 2.0.1" ����set this_text to text contents of selection end tell --This changes the ALL CAPS to lower case makeLowerCase(this_text) set the_new_text to result tell application "InDesign 2.0.1" �--Puts the changed text into the selection ����set text contents of selection to the_new_text --Changes the case of the selection to small caps ����set capitalization of selection to small caps end tell on makeLowerCase(this_text) ����set the_upper_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ����set the_lower_string to "abcdefghijklmnopqrstuvwxyz" ����set the_new_text to "" ����repeat with thisChar in this_text ��������set x to offset of thisChar in the_upper_string ��������if x is not 0 then ������������set the_new_text to (the_new_text & character x of the_lower_string) as string ��������else ������������set the_new_text to (the_new_text & thisChar) as string ��������end if ����end repeat ����return the_new_text end makeLowerCase The subroutine "makeLowerCase" is a modification of what Dave posted yesterday. If what you really end up needing is title case for "Paho" in small caps (cap for "P" and small caps for "AHO"), you should use Dave's "makeTitleCase" subroutine and change the line above "makeLowerCase(this_text)" to "makeTitleCase(this_text)" and it would work. Does this make sense? Thanks, Carl
Technical Details
Message-ID:
<ef973c0.5@WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef973c0.-1@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,7eef1716469144d7 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-07-03 08:10:21 PST From: "Carl Davaz" <cdavaz@guardnet.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Change case of selected text? (AS) Message-ID: <ef973c0.5@WebX.aaQKaf7vad4> Date: Wed, 3 Jul 2002 08:00:46 -0700 References: <ef973c0.-1@WebX.aaQKaf7vad4> Lines: 63 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit