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

Re: preflighting a file


  • Subject: Re: preflighting a file
  • From: Andy Wylie <email@hidden>
  • Date: Tue, 19 Feb 2002 16:21:22 +1300

on 19/2/02 1:54 PM, Shane Stanley at email@hidden wrote:

> On 19/2/02 10:32 AM +1000, Pat Cannon, email@hidden, wrote:
>
>> Try this (you'll probably have to fix a couple line breaks):
<snip> script
>> You can probably speed it up by making chunksize bigger -- this took a
>> minute and a half to read through a 4.8MB file on my G4.
>
> But you're not allowing for the possibility of "CalGray" falling across the
> boundary of two chunks. To be safe, you need to do something like store the
> last paragraph of each chunk, then concatenate the next chunk to it each
> time.
>
> You would also speed things up a fair bit if you used "open for
> access"/"close access"; as it stands, opening and closing being done
> (automatically) each time you read. As a bonus, you would then no longer
> have to keep track of where you were in the file -- you would just "read for
> 1024" each time.

But this still errors when it hits eof, my crude fix (with no good reason
not to use offset(yet:))...
-------------
on open theFile
set |eof| to get eof of file theFile
open for access alias theFile
try
set startChunk to 1
repeat
set endChunk to startChunk + 4024
if endChunk > |eof| then set endChunk to |eof|--no error -39
set theText to read theFile from startChunk to endChunk
if startChunk > 1 then
set startChunk to endChunk - 10
else
set startChunk to endChunk
end if
if (offset of "CalGray" in theText) > 0 then
display dialog "CalGray @ offset" & (offset of "CalGray" in
theText)
exit repeat
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.

  • Follow-Ups:
    • Re: preflighting a file
      • From: Shane Stanley <email@hidden>
References: 
 >Re: (no subject) (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: preflighting a file
  • Next by Date: Re: Filemaker scripts [newbie post]
  • Previous by thread: Re: (no subject)
  • Next by thread: Re: preflighting a file
  • Index(es):
    • Date
    • Thread