Re: jmlbeud ceararhtcs
Re: jmlbeud ceararhtcs
- Subject: Re: jmlbeud ceararhtcs
- From: Walter Ian Kaye <email@hidden>
- Date: Sun, 21 Sep 2003 13:11:11 -0700
OK, here ya go:
set str to "That's me, in the spotlight."
set endPos to 0
set wordLen to 0
set cList to every character of str
repeat with w in (words of str)
set begPos to AtOffset(w, str, endPos + 1)
set wordLen to length of w
set endPos to begPos + wordLen - 1
if wordLen > 2 then
set bmPos to begPos + 1
set emPos to endPos - 1
set mixLen to wordLen - 2
set mixStr to text bmPos thru emPos of str
set rList to RandomizeNumbers(mixLen)
repeat with i from 1 to mixLen
set item (bmPos + i - 1) of cList to character (item i of
rList) of mixStr
end repeat
end if
end repeat
set outstr to cList as string
on RandomizeNumbers(maxNum)
if maxnum > 34 then error "RandomizeNumbers() takes integers up to 34."
local maxNum, numList, randomList, c, rn
set numList to items 1 thru maxNum of {1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34}
set randomList to {}
repeat with c from 1 to maxNum
repeat
set rn to some item of numList
if class of rn is integer then exit repeat
end repeat
set item rn of numList to ""
set end of randomList to rn
end repeat
randomList
end RandomizeNumbers
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
_______________________________________________
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.