Re: Saving lists of records to a text file
Re: Saving lists of records to a text file
- Subject: Re: Saving lists of records to a text file
- From: has <email@hidden>
- Date: Tue, 28 May 2002 12:21:54 +0100
JollyRoger wrote:
>
> 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:
>
>
Yes, that's an option. But using script objects to store properties between
>
loads is *extremely* slow in my experience - way too slow in an environment
>
where you are loading multiple plugins.
Any chance of citing some examples/performance differences? I'd be
interested to know.
In any case, someone's already pointed out to me that SA's read/write
commands have been fixed in newer versions of AS (1.6?/1.7? - anyone
know?), so those should be a practical option (just stuff everything into a
record) unless you're still living in the Stone Age like me.
My guess would be that the problem stems from AS's "me and all the family's
coming too" approach to storing scripts. Not only does the script object
you specify get stored, but everything else around it too. So even if the
script object you intend to save is a itty-bitty little thing, if it's part
of a 100K script holding 1000K of data then you're going to end up saving
1100KB+ of data to disk whether you want to or not.
Fortunately, you can get around this nonsense by keeping your 'prefs'
object in a different context. For example:
======================================================================
property prefsObj : run script "
script
property _theValue : missing value
end script"
on storeVal(theValue, fileRef)
copy prefsObj to newObj
store script newObj in file (fileRef as string) replacing yes
end storeVal
on loadVal(fileRef)
load script file (fileRef as string)
_theValue of result
end loadVal
======================================================================
This example uses a 'run script' to create the 'prefs' object, but you
could just as easily load it from a separate file on disk. Of course, it
you go on to store script objects within the thing then you're back to
where you started, but I'd think this would be the case no matter what
method you used.
(If you get a chance to give this a spin, I'd be interested to know how it
compares.)
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.