• 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 08:17:44 +1000

has wrote:
Chris wrote:

I know how to read and write a list of records to a file using the "as
list" qualifier.
[...]
Does anyone have a code snippet for writing a list of records one at a time and reading them back one at a time until eof?

You don't. You slurp the whole list into memory and work on it there. (This is not to say it's impossible, just a very bad idea.)


A more useful question would be: what are you trying to achieve (i.e. what's the script's purpose)? e.g. If you're needing a persistent, filesystem-based data store that allows random access, then using Standard Additions to read and write serialised AppleScript data structures is really the wrong tool for the job and there are much more appropriate solutions that you should look into (plain text files, XMLLib.osax, System Events' Plist Suite, Database Events, FileMaker Pro, PostgreSQL, etc.).
For this particular case, I'm wanting to transfer playcounts in iTunes between different computers. So I don't need random access. The file is short lived. And I don't really see the point of slurping tens of thousands of records into memory when I don't need more than one at once.

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


_______________________________________________ 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>)

  • Prev by Date: Re: Converting AppleScript Routine to shell, how to write BOM to beginning of file?
  • Next by Date: Contradictory error message
  • Previous by thread: Re: Reading and writing records
  • Next by thread: Re: Reading and writing records
  • Index(es):
    • Date
    • Thread