Re: Building applescript records with lists, accessing applescript records with strings
Re: Building applescript records with lists, accessing applescript records with strings
- Subject: Re: Building applescript records with lists, accessing applescript records with strings
- From: has <email@hidden>
- Date: Fri, 4 Feb 2005 10:29:19 +0000
Malcolm Fitzgerald wrote:
Two of the FAQs on this list are, "How do I build an applescript record
from a list?" and "How do I coerce a string to a variable?".
When folk ask "How do I build an applescript record from a list?",
ninety-nine times out of a hundred what they actually want is a
dynamic, unordered list structure that stores values by arbitrary
key: a dictionary, hash or associative list. BTW, there was a very
good discussion of this just last week: see the thread titled
"definition list recommendations?".
AppleScript doesn't have a built-in dictionary type, but there are
some reasonable third-party alternatives available, e.g. in AppleMods
Types library <http://applemods.sourceforge.net/>. For example, Jason
Bourque's item pricing problem demands a dynamic key-value dictionary
or associative list object. Hacking up a record to use as an ersatz
dictionary is about the worst solution: there's absolutely no reason
to use a badly faked dictionary object when you can use a real one
instead.
...
On a few occasions it does become necessary to manipulate record
properties at runtime, for example, when an application or osax
returns/requires a record with arbitrary property names; e.g. LNS's
XMLTools, which stores XML tag attributes as records. (That's
generally poor design on the application/osax's part, but sometimes
you just have to work with what you've got.) LNS produce a free List
& Record Tools osax which is probably the easiest way to manipulate
records this way.
If you really _must_ go the vanilla code generator route, there's a
much more robust version on my site
<http://freespace.virgin.net/hamish.sanderson/Record.sit>. (The only
thing worse than evil code generators is completely unsafe and
unreliable evil code generators, which most folks' are.) But these
are really tools of last resort, and not something any decent,
civilised AppleScripter should need or want to touch them with a
ten-foot pole.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden