• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Error: Stack overflow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Error: Stack overflow (From: "G?ran Ehn" <email@hidden>)

  • Prev by Date: Re: Script in Script Editor MUCH faster than compiled app -- why?
  • Next by Date: Re: Language at a Glance
  • Previous by thread: Re: Error: Stack overflow
  • Next by thread: Re: Error: Stack overflow
  • Index(es):
    • Date
    • Thread