• 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: Sorting characters of the text - script doesn't work as expected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting characters of the text - script doesn't work as expected


  • Subject: Re: Sorting characters of the text - script doesn't work as expected
  • From: Yvan KOENIG <email@hidden>
  • Date: Tue, 18 Apr 2017 11:41:52 +0200

Oops

I posted the wrong script. The posted one makes no difference between lowercase and uppercase.

Here is the correct version.

script o
property GreekCharacters : {"α", "β", "γ", "δ", "ε", "ζ", "η", "θ", "ι", "κ", "λ", "μ", "ν", "ξ", "ό", "о", "π", "ρ", "ς", "Ύ", "φ", "χ", "ψ", "ω"}
property noGreekCharacters : {space, " ", "(", ")", "-", "+", "=", "|", "{", "}", "°", "[", "]", "^", "/", "·", "$", "€", "‡", "±", "*", "<", ">", "≥", "≤", "≠", ":", ";", ".", ",", "⁄", "‹", "›", "—", "_", "?", "!", "«", "»", "", linefeed, tab, "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\\"}
property everyCharacters : {}
property uniqueCharacters : {}
property GreekYes : {}
property GreekNo : {}
property allNoGreek : {}
end script


tell application "TextEdit"
activate
set p2d to path to desktop as text
set theFile to p2d & "TXT.txt"
set theDoc to open file theFile
set MyDoc to text of theDoc
end tell

set o's everyCharacters to text items of MyDoc

considering case
# Build a list containing one occurrence of every characters available in the document
set o's uniqueCharacters to {}
repeat with aChar in o's everyCharacters
set aChar to aChar as text


if aChar is not in o's uniqueCharacters then copy aChar to end of o's uniqueCharacters
end repeat


# Build a list of greek characters available in the document
set o's GreekYes to {}
repeat with aGreek in o's GreekCharacters
set aGreek to aGreek as text
if aGreek is in o's uniqueCharacters then
copy aGreek to end of o's GreekYes
end if
end repeat


set o's allNoGreek to o's noGreekCharacters & o's GreekYes
# Build a list of non greek characters available in the document
set o's GreekNo to {}
repeat with noGreek in o's uniqueCharacters
set noGreek to noGreek as text
if noGreek is not in o's allNoGreek then
copy noGreek to end of o's GreekNo
end if
end repeat


end considering

{o's GreekYes, count o's GreekYes, linefeed, o's GreekNo, count o's GreekNo}


Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) mardi 18 avril 2017 11:41:39





 _______________________________________________
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: Sorting characters of the text - script doesn't work as expected
      • From: ILJA SHEBALIN <email@hidden>
References: 
 >Sorting characters of the text - script doesn't work as expected (From: ILJA SHEBALIN <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: Christopher Stone <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: ILJA SHEBALIN <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: Yvan KOENIG <email@hidden>)
 >Re: Sorting characters of the text - script doesn't work as expected (From: ILJA SHEBALIN <email@hidden>)

  • Prev by Date: Re: Sorting characters of the text - script doesn't work as expected
  • Next by Date: Re: Sorting characters of the text - script doesn't work as expected (Yvan KOENIG)
  • Previous by thread: Re: Sorting characters of the text - script doesn't work as expected
  • Next by thread: Re: Sorting characters of the text - script doesn't work as expected
  • Index(es):
    • Date
    • Thread