Re: Error: Stack overflow
Re: Error: Stack overflow
- Subject: Re: Error: Stack overflow
- From: John Delacour <email@hidden>
- Date: Tue, 29 Apr 2003 20:24:58 +0100
- Mac-eudora-version: 6.0a16
At 3:38 pm +0200 29/4/03, Goeran Ehn wrote:
I'm reading a file from disk which is about 1200 lines (52k) which
is not very large in my mind. However I get this error telling me
"stack overflow" when reading large files, smaller files are reads
ok though. Is there a way to control memory in AS or is it just a
lack in the script editor (1.8.3 under OS 9.2.2)? Any workarounds
for this kind of problem?
This is a FAQ that I've answered many times on the lists over the
years. No complicated routine is required.
All you need to do is read in chunks. Ican read in chunks of 100,000
with no problem, but it makes little difference. Just set the chunk
size to what you want. When you get to the end of file, you will get
an error, so trap this error in a try block and exit the loop. You
will find that you have reald all the file, including the bit at the
end which is not the full size of your specified chunk.
tell app "Eudora" to set f to file of mailbox "In"
--> or ANY file specification or alias
open for access f
repeat
try
set chunk to read f for 20000
on error
exit repeat -- **** MOST IMPORTANT
end try
end repeat
close access f
length of chunk
_______________________________________________
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.