• 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: read from file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read from file


  • Subject: Re: read from file
  • From: Andy Wylie <email@hidden>
  • Date: Mon, 05 Aug 2002 20:00:13 +1200

on 5/8/02 2:54 PM +1200: email@hidden wrote:


> Everything works fine until I try to load a large file into a variable.
> Then I get an "out of memory" error.
>
this is an FAQ so please excuse this old example of reading chunks...

on open theFile
set |eof| to get eof of file theFile
open for access alias theFile
try
set startChunk to 1
set endChunk to 0
repeat until endChunk = |eof|
set endChunk to startChunk + 4024
if endChunk > |eof| then set endChunk to |eof|
set theText to read theFile from startChunk to endChunk
if (offset of "CalGray" in theText) > 0 then
display dialog "CalGray @ offset " & startChunk + (offset of
"CalGray" in theText)
exit repeat
end if
if startChunk > 1 then
set startChunk to endChunk - 10
else
set startChunk to endChunk
end if
end repeat
close access theFile
on error m number n
error {n, m}
close access theFile
end try
end open

_____________________________ Andy
_______________________________________________
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: 
 >read from file (From: email@hidden)

  • Prev by Date: Re: Misc Eudora questions
  • Next by Date: Re: How do I escape a question mark (?)
  • Previous by thread: read from file
  • Next by thread: Re: read from file
  • Index(es):
    • Date
    • Thread