Re: processing time & stack overflow
Re: processing time & stack overflow
- Subject: Re: processing time & stack overflow
- From: monk <email@hidden>
- Date: Mon, 27 Aug 2001 01:01:04 -0400
-- 8/25/01 9:58 PM: email@hidden said:
oops, last version was not working
On 8/25/01 4:34 PM, "monk" <email@hidden> wrote:
>
i'm back refining my 'text art project' script
I have no idea what the idea of the script is, but this seems a quicker way
to create files consisting of every word of a source file written out in
random order (plus a bunch of eye candy up front)
cheers,
tim
hi tim (prof. bates) - well it's a 'cross cutting' script which is a modern
technique of text manipulation, for effect i guess, used to be done
manually, etc., like everything else
anyways, thanks for your input, i have yet to do a detailed comparison, but
on first try i get an Execution Error on open folder _newfolder, that
"Finder got an error: Can't make some data into expected type." so, i
replaced the dialog with my original one and it worked fine - then i ran
some tests
well, i saved the script as an applet and ran it on my 'big' file procesing
by 'word', and it crunched along but allowed me to multi-task, that was
good, however i assigned the script 128 mb and it still had a stack
overflow, and showed no noticeable signs of speed improvement, even though
it didn't write until the end, as well it was hard to tell whether the file
was processing or not as the cursor would flicker between busy and an arrow
(when i ran it as a script it always showed busy?, which was better (another
item i've been testing is adding a progress bar))
on small files it seems to process fine, and when i watch the event log,
even differently(?), i'm not sure if i'm running into applescript
limitations or what? maybe this would be better handled in macperl, or even
java or lisp? it seems like once the file has been read and the words all
assigned numbers, the processing takes palce in a black hole that i have no
access to, so i can't tell what's jamming up, or how to redesign the routine
anyway, much appreciated and i beleive it is an improvement
thanks a bunch
set _source to open for access (choose file with prompt "choose source to
juxtapose:")
display dialog "process by:" buttons {"line", "paragraph", "word"} default
button "word"
set _buttonreply to button returned of result
if _buttonreply is "word" then
set fileDelimitters to {return, space} --read variable as list by word
and set new variable for list manipulation
else if _buttonreply is "line" then
set fileDelimitters to {return} --read variable as list by line
(sentence)
else --"paragraph"
set fileDelimitters to {return & space} --read variable as list by
paragraph (word & line)
end if
try
set _listsource to (read _source as list using delimiter
fileDelimitters)
close access _source
on error
try
close access _source
end try
end try
--return _listsource
set _fileamount to "1"
repeat until class of _fileamount is integer and _fileamount > 0 and
_fileamount < 100
try
set _fileamount to (text returned of (display dialog "enter amount
of files to generate from source (1-99)?" default answer _fileamount giving
up after 12)) as integer
on error
display dialog "that wasn't the right kind of number!"
end try
end repeat
tell application "Finder"
activate
set _newfolder to (path to desktop as string) & "juxtatext(s)"
try
open folder _newfolder
on error
set _newfolder to make new folder at desktop with properties
{name:"juxtatext(s)"}
open folder _newfolder
end try
set size of window of folder _newfolder to {253, 527}
set view of window of folder _newfolder to kind
end tell
try
repeat with i from 1 to _fileamount
set _filename to "juxtatext " & characters -2 thru -1 of ("0" & i)
set _juxtatext to open for access file (((path to desktop) as string)
& "juxtatext(s):" & _filename) with write permission
my juxtapose(_listsource, _juxtatext)
close access _juxtatext
end repeat
on error errmsg number errNbr
try
close access _juxtatext
end try
error errmsg number errNbr
end try
on juxtapose(_listsource, _juxtatext)
set _listsource to my randomize(_listsource)
set {AppleScript's text item delimiters, oldTIDs} to {{" "}, AppleScript's
text item delimiters}
set _listsource to _listsource as string
write (_listsource) to _juxtatext starting at eof
set AppleScript's text item delimiters to oldTIDs
end juxtapose
to randomize(TheList)
repeat with i from length of TheList to 1 by -1
set current_item to (random number from 1 to i)
tell TheList -- exchange item current_item with item i
set temp to item i
set item i to item current_item
set item current_item to temp
end tell
end repeat
return TheList
end randomize
Dr Timothy Bates <
mailto:email@hidden>
Macquarie Centre for Cognitive Science (MACCS)
Macquarie University
Ph 61 (2) 9850 8623
Fx 61 (2) 9850 6059
h 'monk' elmer
--
% % % %
http://www.assemblage.org
% % % %