• 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: jmlbeud ceararhtcs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: jmlbeud ceararhtcs


  • Subject: Re: jmlbeud ceararhtcs
  • From: Walter Ian Kaye <email@hidden>
  • Date: Sun, 21 Sep 2003 09:17:27 -0700

At 04:49p +0200 09/21/2003, Brennan didst inscribe upon an electronic papyrus:

set str to "I'm intrigued by recently popularised linguistic
research which shows that any text where the
letters of individual words are jumbled is more or less legible,
provided that the first and last characters of each word are correct.
Longer words seem to suffer most, as you can see.
I have written a script which performs this text transformation
but I feel it could be improved. In particular, I can't see a
neat way of retaining punctuation marks. Does anyone want to
take a shot at it?"

The problem is that punctuation marks are being considered as word breaks, so when you get the words of the string, you've lost them.

What you can do is the following:

set lastLetter to 0
repeat with w in (words of str)
set firstLetter to AtOffset(w, str, lastLetter + 1)
set lastLetter to firstLetter + (length of w) - 1
--do your stuff here

end repeat


on AtOffset(find, within, beg)
local find, within, beg, pos
try
set pos to offset of find in (text beg thru -1 of within)
if pos > 0 then
return pos + (beg - 1)
else
return 0
end if
on error
return 0
end try
end AtOffset


set wds to (words of str)
set output to ""
set AppleScript's text item delimiters to ""

repeat with w in wds
set chrs to (characters of w)
set ccount to (count chrs)
set firstLetter to (character 1 of w)
set lastLetter to (character -1 of w)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >jmlbeud ceararhtcs (From: Brennan <email@hidden>)

  • Prev by Date: [OT] Re: jmlbeud ceararhtcs
  • Next by Date: [OT] Re: jmlbeud ceararhtcs
  • Previous by thread: Re: [OT] Re: jmlbeud ceararhtcs
  • Next by thread: Re: jmlbeud ceararhtcs
  • Index(es):
    • Date
    • Thread