🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #20673

Re: Change case of selected text? (AS)

#20673
From: Dave Saunders
Date: Tue, 02 Jul 2002 22:22
53 lines
2508 bytes
Here's a couple of subroutines I use to do the job. Actually, I don't have a to lowercase version, but the makeUpperCase subroutine should give you the idea. 

on makeTitleCase(this_text) 

 set oldDelims to AppleScript's text item delimiters 
�set AppleScript's text item delimiters to {""} 
�set the_upper_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 
�set the_lower_string to "abcdefghijklmnopqrstuvwxyz" 

 set theInitCap to character 1 of this_text 
�set x to offset of theInitCap in the_lower_string 
�if x is not 0 then 
��set theInitCap to character x of the_upper_string 
�end if 

 set this_text to characters 2 through -1 of this_text as string 

 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 

 set the_new_text to theInitCap & the_new_text 

 set AppleScript's text item delimiters to oldDelims 
�return the_new_text 
end makeTitleCase 

on makeUpperCase(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_lower_string 
��if x is not 0 then 
���set the_new_text to (the_new_text & character x of the_upper_string) as string 
��else 
���set the_new_text to (the_new_text & thisChar) as string 
��end if 
�end repeat 

 return the_new_text 
end makeUpperCase 
 

Dave
Technical Details
Message-ID: <ef973c0.0@WebX.aaQKaf7vad4>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!64.152.100.70.MISMATCH!ps01-sjc1!news.webusenet.com!newsfeed1.cidera.com!Cidera!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <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-02 15:39:29 PST
From: "Dave Saunders" <daves@pdsassoc.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!64.152.100.70.MISMATCH!ps01-sjc1!news.webusenet.com!newsfeed1.cidera.com!Cidera!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.0@WebX.aaQKaf7vad4>
Date: Tue, 2 Jul 2002 15:22:47 -0700
References: <ef973c0.-1@WebX.aaQKaf7vad4>
Lines: 57
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit