• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Text - change case
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text - change case


  • Subject: Re: Text - change case
  • From: Mr Tea <email@hidden>
  • Date: Thu, 19 May 2005 17:38:09 +0100

Title: Re: Text - change case
This from Ruby Madraswala - dated 19/5/05 2.00 pm:

Write counter & “ “ & item x of wordlist & return to outfile
 
Item x of wordlist is in upper case: ex. APPLE COMPUTER and I want to write this as Apple Computer. Item x of wordlist can be one word or up to 5 words.




If this is all you need to do, you don’t really need a full featured case converter or shell script. Here’s how I might approach it, just off the top of my head...

set x to "APPLE COMPUTER"


set returnString to ""
set
lc to "abcdefghijklmnopqrstuvwzyz"
set counter to 0
set xWords to every word of x
repeat with aWord in xWords
   set counter to counter + 1
   set xWordLetters to every text item of aWord
   set tempword to {text item 1 of aWord}
    
repeat with x from 2 to count xWordLetters
       set pos to offset of (get item x of xWordLetters) in lc
       set posRes to text item pos of lc
       copy posRes to end of tempword
   end repeat
   if
counter = 1 then
       set
returnString to returnString & tempword
   else
       set
returnString to returnString & space & tempword
   end if
end
repeat

returnString --> "Apple Computer"


(Tested but not optimised.) AppleScript is case insensitive unless you tell it to be otherwise. Here, it ignores the case of the letters in X, but honours the case of the letters in the alphabetic list when appending them to the returned string. If you need accented letters too, just add them to the end of the alphabetic list.



Nick
pp Mr Tea

--

 _______________________________________________
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

  • Follow-Ups:
    • Re: Text - change case
      • From: Emmanuel <email@hidden>
    • Re: Text - change case [Erratum 2]
      • From: Mr Tea <email@hidden>
    • Re: Text - change case [Erratum]
      • From: Mr Tea <email@hidden>
References: 
 >Text - change case (From: "Ruby Madraswala" <email@hidden>)

  • Prev by Date: Re: Text - change case
  • Next by Date: Re: Text - change case [Erratum]
  • Previous by thread: Re: Text - change case
  • Next by thread: Re: Text - change case [Erratum]
  • Index(es):
    • Date
    • Thread