• 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: Reformatting a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reformatting a string


  • Subject: Re: Reformatting a string
  • From: Shane Stanley <email@hidden>
  • Date: Tue, 31 Jan 2012 09:26:36 +1100

On 31/01/2012, at 1:59 AM, KOENIG Yvan wrote:

script capNStuff
set x to current application's NSApp's convertedValue()
set x to x's componentsSeparatedByString_(":")
set x to x's componentsJoinedByString_("")
set x to x's uppercaseString()
end script
script lowNStuff
set x to current application's NSApp's convertedValue()
set x to x's componentsSeparatedByString_(":")
set x to x's componentsJoinedByString_("")
set x to x's lowercaseString()
end script
if mode is "upper" then
if txt contains "ß" then
(*
Required to convert ß if we don’t want to get SS *)
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to "ß"
set l to text items of txt
set AppleScript's text item delimiters to character id 7838
set txt to "" & l
set AppleScript's text item delimiters to oTIDs
end if
tell application "ASObjC Runner" to set txt to (run the script {capNStuff} converting txt with result returned)
else if mode is "lower" then
tell application "ASObjC Runner" to set txt to (run the script {lowNStuff} converting txt with result returned)
end if

On the chance that someone actually wants to use it, let me at least simplify it a bit:

script capNStuff
set x to current application's NSApp's convertedValue()
set mode to current application's NSApp's passedValue() as text
set x to x's stringByReplacingOccurrencesOfString_withString_(":", "")
if mode = "upper" then
-- set x to x's stringByReplacingOccurrencesOfString_withString_("ß", character id 7838)
return x's uppercaseString()
else
return x's lowercaseString()
end if
end script

tell application "ASObjC Runner" to set txt to (run the script {capNStuff} converting txt passing mode with result returned)


-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Rép: Reformatting a string (From: KOENIG Yvan <email@hidden>)
 >Re: Rép: Reformatting a string (From: Thomas Fischer <email@hidden>)
 >Re: Reformatting a string (From: KOENIG Yvan <email@hidden>)

  • Prev by Date: giving up
  • Next by Date: Re: giving up
  • Previous by thread: Re: Reformatting a string
  • Next by thread: Re: Reformatting a string
  • Index(es):
    • Date
    • Thread