Re: Write a prefs file
Re: Write a prefs file
- Subject: Re: Write a prefs file
- From: Christopher Nebel <email@hidden>
- Date: Fri, 31 May 2002 09:42:13 -0700
On Friday, May 31, 2002, at 04:37 AM, JollyRoger wrote:
Ok now I see the source of my confusion. I assumed that because
Resorcerer
opened these .rsrc files and showed me a list of resources, the files
had no
data fork. I appears now that what Resorcerer was actually doing was
reading the data fork and displaying the resources as if they were in
the
resource fork. Man, that's misleading!
Aha! Yes, Resorcerer is smart about these things. (Perhaps a little
*too* smart, from the sound of it.) If you'd used an older, dumber
program like ResEdit, it would have complained. Glad we got that
cleared up.
I have been under the mistaken impression that flattening resource forks
meant converting them to multiple data files. If I can store all of my
resource files in the data fork of one file, and the Resource Manager
can
read them the same way as before, there's no reason for me not to
switch to
flattened resource files. This seems to be the case.
Right. The only reason to use separate files is to switch to a
fundamentally different format like .strings or .nib files, or perhaps
if you wanted to segregate your Resource Manager resources into a couple
of different files for some reason. (I've never heard of anyone doing
this, but you never know.)
Would it be possible, from Carbon Resource Manager APIs, to create
flattened
resource files? (Might someone write a scripting addition that would
allow
a script to create flattened resource files?)
You betcha -- use FSCreateResourceFile passing null as the fork name.
(To open one, use FSOpenResourceFile, again with a null fork name.)
After that, it's just another refNum, so all the regular APIs work
normally.
All of this is only partially relevant to the topic of the original
message.
What is the preferred mechanism to use to write preferences files from
AppleScript?
Indeed. :) My stance is that you can use whatever is most convenient
for you and your users. Since preference files are by definition
peculiar to an application, there's really no such thing as a "real"
preference file format. Now, there are formats that lots of people tend
to use, like plists on Mac OS X, but that's more because there's a very
easy API for them than anything else.
Given that AppleScript doesn't have any built-in Resource Manager calls,
"most convenient for you" probably means writing something into the data
fork, whether with read/write or store script. If you wanted to be Just
Like Cocoa (tm), "something" would be an XML plist, but it doesn't
matter that much, unless you like the idea of users being able to look
in the preference file and see what's going on.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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.