processing time & stack overflow
processing time & stack overflow
- Subject: processing time & stack overflow
- From: monk <email@hidden>
- Date: Sat, 25 Aug 2001 02:34:56 -0400
hi all -
after a bit of a hiatus, i'm back refining my 'text art project' script
(which many of you have contributed to), and have a few questions i would
like to pose:
on the script below, when i process a file of 10,000 words, i usually end up
with a stack overflow towards the very end of writing the file
so i cancel out, but the file is there and when i do a word count it usually
reads something like 9,997 words, i can live with that (and in my opinion it
may be that all of the words have been processed, being that they may have
been recognized and written differently)
any comments on how to get around the overflow, or what is causing it?
next, the processing of the 10,000 word file takes a dozen minutes (pb g3
500, os 9.0.4, ascript 1.4.3) and, all of the resources, it just hogs the
foreground completely, so i'm, left twiddling my thumbs
right now the script reads and writes each item, and that is why it is so
cumbersome, is there a way to force all of the processing into ram, and only
write the file when every item has been processed? this may get rid of the
overflow, and i'm sure would speed up the operation immensely
here it is:
<start script>
try
set _source to open for access (choose file with prompt "choose source
to juxtapose:")
set _buttonreply to button returned of (display dialog "process by:"
buttons {"line", "paragraph", "word"} ,
default button "word")
if _buttonreply is "word" then
--read variable as list by word and set new varaible for list
manipluation
set _listsource to (read _source as list using delimiter {return,
space})
else if _buttonreply is "line" then
--read variable as list by line (sentence)
set _listsource to (read _source as list using delimiter {return})
else
--read variable as list by paragraph (word & line)
set _listsource to (read _source as list using delimiter {return &
space})
end if
close access _source
set _fileamount to "x"
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 "1" 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"
set _newfolder to (make new folder at desktop with properties
{name:"juxtatext(s)"})
open _newfolder
set size of container window of _newfolder to {253, 527}
set view of container window of _newfolder to kind
end tell
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
juxtapose(_listsource, _juxtatext)
close access _juxtatext
end repeat
on error errmsg number errNbr
try
close access _source
end try
try
close access _juxtatext
end try
display dialog (errNbr as text) & " " & errmsg
end try
on juxtapose(_listsource, _juxtatext)
try
set pcount to count of text items of _listsource
repeat until pcount < 1
--set text item delimiters to {return}
set _listsource to text items of _listsource
set k to random number from 1 to pcount
write (contents of item k of _listsource & {space}) starting at
eof to _juxtatext
set item k of _listsource to {}
set _listsource to every string of _listsource
set pcount to pcount - 1
end repeat
set text item delimiters to ""
set _listsource to ""
return 0
on error errmsg
display dialog errmsg as text
end try
end juxtapose
<end script>
besides these issues, which might be inherent in applescript, i'm waiting to
find out, i have a few more items i'm trying to work in, and will be done,
90% + done!
much obliged in many languages
howie 'monk' elmer
--
http://www.assemblage.org