Re: can't make { . . . } into an item [error message] deivy's original again
Re: can't make { . . . } into an item [error message] deivy's original again
- Subject: Re: can't make { . . . } into an item [error message] deivy's original again
- From: monk <email@hidden>
- Date: Mon, 16 Jul 2001 07:42:12 -0400
-- 7/14/01 09:06 pm: email@hidden said:
i got deivy's original working, and changed the tid here and there for
mixing items, added a write and close
anyway though, i found that i always have 1 less item in the result than in
the source file, i.e., if the source has 8 items, the result will have 7,
and so on
i don't mind randomly leaving out items, but is there a way to randomly
include all items too?
thanks
<adapted script>
set _source to open for access (choose file with prompt "choose source to
mix:") with write permission
set _mix to open for access file (((path to desktop) as string) & "mixed")
with write permission
set mytext to (read _source as list using delimiter {return, space}) -- this
is the equivalent of _source
set mymix to (read _mix as list using delimiter return) -- this is the
equivalent of _mix
mix(mytext, mymix) -- this mixes the original source into the new mix
on mix(mytext, mymix)
set zlist to {}
set text item delimiters to {space} -- change to get items, lines, or
paragraphs
set mymix to text items of mymix
set mytext to text items of mytext -- these two lines coerce text into
list
set pcount to count of text items of mytext
repeat with l from 1 to pcount
set zlist to zlist & l -- creating a list to take an element out of
end repeat
set k to contents of some item of zlist -- random element chosen
set mymix to mymix & text item k of mytext -- added to _mix
if k = pcount and k = 1 then --only one line in the _source, let's
finish it up
set mytext to ""
set mymix to rest of mymix
set mymix to mymix as string
set text item delimiters to "" -- restaure to default
return mymix
end if
if k > 1 and k < pcount then set mytext to (text items 1 thru (k - 1) of
mytext) & (text items (k + 1) thru pcount of mytext) as list
if k = 1 and pcount > k then set mytext to items 2 thru pcount of mytext
as list
if k = pcount and pcount > 1 then set mytext to text items 1 thru
(pcount - 1) of mytext as list
mix(mytext, mymix) -- using recurence. You want to do it until _source
is empty
end mix
write result to file (((path to desktop) as string) & "mixed")
close access _source
<adapted script>
h 'monk' elmer
--
//\/\\/\/\//\/\\/\/\//\/\\
http://www.assemblage.org