Article View: adobe.scripting.indesign
Article #20498Re: Change case of selected text? (AS)
From: Carl Davaz
Date: Thu, 04 Jul 2002 04:20
Date: Thu, 04 Jul 2002 04:20
65 lines
2936 bytes
2936 bytes
Aaron,
Your script works really well. It appears you need to make one slight modification. In your repeat statement, change this section:
tell application "InDesign 2.0.1"
search stories of active document with find attributes �
{applied font:"ITC Galliard", find text:(item y of this_text)}
end tell
to be like the modified bit below, then you're there.
tell application "InDesign 2.0.1"
search stories of active document with find attributes �
{applied font:"ITC Galliard", find text:(item y of this_text), case sensitive:true}
end tell
The sentence case goes away when you add the find attribute "case sensitive:true" then you get what you want. Also, the subroutine was Dave's...
So here's your whole script with the changes:
-- What we're searching for
set this_text to {"DFID", "WHO", "UNICEF", "GEM"}
tell application "InDesign 2.0.1"
set find preferences to nothing
set change preferences to nothing
end tell
-- Replace with small caps
repeat with y from 1 to count of this_text
tell application "InDesign 2.0.1"
search stories of active document with find attributes �
{applied font:"ITC Galliard", find text:(item y of this_text), case sensitive:true}
end tell
makeLowerCase(item y of this_text)
set the_new_text to result
--display dialog the_new_text
tell application "InDesign 2.0.1"
search stories of active document with change attributes �
{change text:(the_new_text), capitalization:small caps}
end tell
end repeat
-- AND HERE I'M REPEATING DAVE'S SUBROUTINE
on makeLowerCase(text_to_change)
set the_upper_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set the_lower_string to "abcdefghijklmnopqrstuvwxyz"
set the_new_text to ""
repeat with thisChar in text_to_change
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
Thanks,
Carl
Technical Details
Message-ID:
<ef973c0.13@WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-01!supernews.com!nntp2.aus1.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!amsnews01.chello.com!newsfeed.freenet.de!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 21:38:32 PST From: "Carl Davaz" <cdavaz@guardnet.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-01!supernews.com!nntp2.aus1.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!amsnews01.chello.com!newsfeed.freenet.de!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.13@WebX.aaQKaf7vad4> Date: Wed, 3 Jul 2002 21:20:20 -0700 References: <ef973c0.-1@WebX.aaQKaf7vad4> Lines: 71 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit