Re: can't make { . . . } into an item [error message] - deivy's optimized example
Re: can't make { . . . } into an item [error message] - deivy's optimized example
- Subject: Re: can't make { . . . } into an item [error message] - deivy's optimized example
- From: monk <email@hidden>
- Date: Sun, 15 Jul 2001 23:57:38 -0400
-- 7/15/01 10:46 am: email@hidden said:
>
Ok, based on Michelle's script from yesterday, some lines that I
>
forgot to put in, and, a clever idea by another scripter, this is a
>
faster and shorter version of the script I sent you yesterday. Notice
>
that this script stops only when the original text have all been
>
mixed. I thought that's what you wanted.
>
yup, ok i ran it and removed the double dashes, and at the delimiters line,
i chose {return, space}, and got this syntax error message: Expected end of
line, etc. but found "{".
wondering how to get around that?
howie monk
>
<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 with delimiters {a,b} -- put you delimiters
>
here.
>
>
set mytext to "this is the beginning of my text
>
this is the second line of my text
>
this is the third line
>
and finally the forth line " -- this is the equivalent of _source
>
>
set mymix to "" -- this is the equivalent of _mix
>
>
mix(mytext, mymix) -- this mixes the original source into the new mix
>
--set l to mix(mytext, mymix)
>
--write l to _mix
>
--close access _mix
>
>
on mix(mytext, mymix)
>
set text item delimiters to return -- you want to get the 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
>
set k to random number from 1 to pcount -- random element
>
chosen. Michelle Steiner's better line of code
>
set mymix to mymix & text item k of mytext -- added to _mix
>
if pcount = 1 then
>
set mymix to rest of mymix
>
set mymix to mymix as string
>
set text item delimiters to "" --default
>
return mymix
>
end if
>
set item k of mytext to {}
>
set mytext to every string of mytext -- Arthur Knapp's clever idea
>
mix(mytext, mymix) -- using recurrence. You want to do it
>
until _source is empty
>
end mix
>
>
</script>
>
>
Deivy Petrescu
>
http://www.dicas.com
>
Tips for your Mac.
>
Dicas para o seu Mac.
>
mailto:email@hidden
>
mailto:email@hidden