Re: set var to foo; get var of record?
Re: set var to foo; get var of record?
- Subject: Re: set var to foo; get var of record?
- From: has <email@hidden>
- Date: Fri, 18 Oct 2002 01:20:52 +0100
Terje Bless wrote:
>
>It is technically possible to do this departing from an AppleScript
>
>record, but it's slow and ugly and not meant to be. This is one of
>
>several thousand fundamental shortcomings in AppleScript.
>
>
Pity. This would have made any number of my little projects ever so much
>
easier. Is there any particular reason why this is not available in
>
AppleScript? Is it just that nobody has gotten around to implement it yet,
Yup, I think you just hit the proverbial nail there. (Hashes, regexes,
native filter clauses, blah, blah, blah, blah, blah...) As JD says, AS is
currently lagging just the _teensiest_ bit behind [every single modern
scripting language worth a damn]. But hey, we're all sunny optimists
here... no doubt it'll catch up one of these days/years/millennia [we hope].
Till then, it's a matter of rolling your own (or begging the monks to hurry
up and add decent OSA support to Perl). Here's an associative array library
I wrote a while back that you might want to try:
<
http://www.barple.pwp.blueyonder.co.uk/libraries/index.html#associativeArrayLib
>
It's fairly fast (by AS standards); internally it uses TIDs for key
lookups, which gives close to O(1) performance, at least until the number
of keys gets really large. Keys are pretty much limited to ASCII strings,
integers and reals [1], though values can be anything. Optional
case-/diacritical-insensitivity (off by default as it's slower) is
supported for the MacRoman characterset, and there's a couple other
interesting bits and pieces to play with. Example:
property associativeArrayLib : load script (alias "your path to AALib here")
...
set myArray to associativeArrayLib's newAssociative({})
myArray's setValue("foo", "some text")
myArray's getValue("foo")
--> "some text"
HTH
has
[1] Unicode keys could be supported if needed, assuming TIDs have finally
gotten their act together. (I believe there's previously been <ahem>
"issues" using TIDs with unicode text.)
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of 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.