• 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: Saving lists of records to a text file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving lists of records to a text file


  • Subject: Re: Saving lists of records to a text file
  • From: has <email@hidden>
  • Date: Mon, 27 May 2002 12:36:30 +0100

JollyRoger wrote:

>> is there a way to save these lists of records to a file
>
>Must it be a text file? Do you care about the format of the file, or do you
>just simply want to be able to restore the data in your script when you need
>access to it again? If the latter is the case, consider the following:

The read/write functions in Standard Additions are supposed to allow
reading and writing of various [non-string] data types to file. Alas, IIRC
it's buggy as anthills - at least in older versions of AS.


>I use the following method to store data between loads of various plugins.
>My main script saves the data (a global property) as a resource into a prefs
>file before unloading the plugin.

If prefs files aren't desirable, or Akua Sweets isn't an option for
portability/OS X reasons, you can do the same sort of thing using script
objects and 'store script' and 'load script' from Standard Additions:

======================================================================

on storeVal(theValue, fileRef)
script
property _theValue : theValue
end script
store script result in file (fileRef as string)
end storeVal

on loadVal(fileRef)
load script file (fileRef as string)
_theValue of result
end loadVal

--TEST

set x to {{a:1, b:2, c:3}, {a:4, b:5, c:6}}

set fileRef to "bob:xVal" -- YOUR PATH HERE


storeVal(x, fileRef)
loadVal(fileRef)
--> {{a:1, b:2, c:3}, {a:4, b:5, c:6}}

======================================================================

You can, of course, have any number of properties within the script object
- this is just a simple demonstration.

HTH

has

--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
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: Saving lists of records to a text file
      • From: JollyRoger <email@hidden>
  • Prev by Date: Re: Recalculation of AppleWorks Spreadsheet
  • Next by Date: Re: inconsistencies in getting a non-existent object
  • Previous by thread: Re: Saving lists of records to a text file
  • Next by thread: Re: Saving lists of records to a text file
  • Index(es):
    • Date
    • Thread