• 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: Reading and writing records
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading and writing records


  • Subject: Re: Reading and writing records
  • From: Chris <email@hidden>
  • Date: Sat, 25 Aug 2007 19:03:43 +1000

Philip Aker wrote:
The point is that if you want to use AppleScript list and record formatting in this way, you actually have to know the details of the binary file format for both lists and records and then concoct a few handlers to be able to do what AppleScript doesn't handle natively. And it's slow compared to all of the other choices.

I don't see why I need to know the binary format. I've got no problem writing and reading the records. It just seems strange that there is no way to check for eof.


However to address what I think is your specific question, there are at least two ways I know how to solve the problem and I'm not certain which would be more appropriate for your case. The criteria are whether or not the records are all the same size and exactly how this "list of records" will be formatted on disk. For the latter, what I mean is either it's:

1. Write an AppleScript list of AppleScript records to disk in such a way that one can append an individual record to the file on disk and read it either as a whole into an AppleScript list or by examining it's records one at a time.

or it's:

2. Write an _array_ of AppleScript records to disk in such a way that one can append an individual record to the file on disk. This format will not handle reading the whole as an AppleScript list. The only choice is to read one record at a time until an eof condition.

So basically, if you present details of your record format, then folks would have a better idea of the best kind of solution.

They are just applescript records. Nothing special.

Can anyone give me a code snippet for testing for eof while reading records? A simple thing that my applescript book doesn't cover.

Unless you have fixed-sized records, Shane's post about using a 'try' handler is really the only choice.

I don't see what having fixed size records has got to do with anything when you are reading sequentially. The classic case of sequential variable sized records is a plain text file. If try handers are the only way, so be it, but it seems odd there is no way to explicitly check.



If you can warp the format (on disk) to a fixed-size, then I believe you'll benefit by a speed improvement. See Nigel Garvey's article: <http://macscripter.net/articles/437_0_10_0_C/> for a few ideas.



Philip Aker email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Reading and writing records
      • From: Philip Aker <email@hidden>
References: 
 >Re: Reading and writing records (From: has <email@hidden>)
 >Re: Reading and writing records (From: Chris <email@hidden>)
 >Re: Reading and writing records (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: AppleScript/Automator Help
  • Next by Date: Re: Reading and writing records
  • Previous by thread: Re: Reading and writing records
  • Next by thread: Re: Reading and writing records
  • Index(es):
    • Date
    • Thread