Re: jmlbeud ceararhtcs
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.