Re: Error: Stack overflow
Re: Error: Stack overflow
- Subject: Re: Error: Stack overflow
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 30 Apr 2003 00:08:56 -0700
On 4/29/03 10:12 PM, "Shane Stanley" <email@hidden> wrote:
>
On 30/4/03 10:50 AM +1000, John Delacour, email@hidden, wrote:
>
>
> I have used this routine for 15 years.
>
>
Use it on a system pre-10.2 with a file that's shorter than your chunk size.
>
I think you'll find it falls down rather badly.
Before John ever answered, I supplied an equivalent script that would not
fail on short chunks. It has been ignored here (except by Goran who asked
the question originally, and also by Chris Nebel who doesn't think that
reading any text shorter than 1 GB fails - at least in the most recent AS
version). Personally, I feel that the limit, if there is one, is somewhere
closer to 30 MB than 30 KB, but - like JD - it seems to me that if you keep
it small enough, things will never go wrong. Here it is again:
set fileRef to open for access alias "file:path"
try
set r to read fileRef
on error
set r to my ReadPartials(fileRef)
end try
close access fileRef
on ReadPartials(fileRef)
local b, y, r, textClump
set b to 1
set y to 30000
set r to ""
set finished to false
repeat until finished
try
set textClump to read fileRef from b to y
set r to r & textClump
on error -- last text clump
set textClump to read fileRef from b to eof
set r to r & textClump
set finished to true
end try
set {b, y} to {b + 30000, y + 30000}
end repeat
return r
end ReadPartials
--
Paul Berkowitz
_______________________________________________
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.