• 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: TID & text items issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TID & text items issue


  • Subject: Re: TID & text items issue
  • From: "koenig.yvan" <email@hidden>
  • Date: Wed, 24 Oct 2012 01:21:36 +0200

Hello

Here is the handler which I use to achieve this goal when I'm not allowed to use a third party tool :


#=====
(*
replace every groups of spaces by single one and remove leading and trailing spaces in the text t
*)
on nettoieEspaces(t)
local oTIDs, l, tt, i
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, space}
set l to text items of t
set AppleScript's text item delimiters to ""
set tt to "" & l
set nbSpaces to (count t) - (count (tt))
set AppleScript's text item delimiters to oTIDs
if nbSpaces > 0 then
set l to {}
repeat with i from nbSpaces to 2 by -1
set tt to ""
repeat i times
set tt to tt & space
end repeat
copy tt to end of l
end repeat
set AppleScript's text item delimiters to l
set l to text items of t
set AppleScript's text item delimiters to space
set t to "" & l
if t is space then return t
if t starts with space then set t to text 2 thru -1 of t
if t ends with space then set t to text 1 thru -2 of t
end if # nbSpaces > 0
return t
end nettoieEspaces


Yvan KOENIG (VALLAURIS, France) mercredi 24 octobre 2012 01:18:15


 _______________________________________________
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

  • Follow-Ups:
    • Re: TID & text items issue
      • From: Christopher Stone <email@hidden>
References: 
 >TID & text items issue (From: "John C. Welch" <email@hidden>)
 >Re: TID & text items issue (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: TID & text items issue
  • Next by Date: Re: TID & text items issue
  • Previous by thread: Re: TID & text items issue
  • Next by thread: Re: TID & text items issue
  • Index(es):
    • Date
    • Thread