Re: Dynamic Records?? (or other alternatives)
Re: Dynamic Records?? (or other alternatives)
- Subject: Re: Dynamic Records?? (or other alternatives)
- From: has <email@hidden>
- Date: Sat, 1 Dec 2001 13:54:24 +0000
Arthur J Knapp wrote:
>
A number of great vanila methods for acomplishing this have been
>
posted in the past. Check out these emulated hash techniques:
[snip]
>
Another method that I once posted is here:
>
>
<http://archives:email@hidden/mhonarc/applescript-users/msg14908
>
.html>
And here it's without the deliberate mistake <g> (eh, Arthur?;):
======================================================================
script LabeledStrings
property kDelim : ASCII character 1
property sData : kDelim
on GetString(the_label)
set oldDelim to text item delimiters
set text item delimiters to kDelim & kDelim & the_label & kDelim
if ((count of text items in sData) = 3) then
set str to text item 2 of sData
else
set str to ""
end if
set text item delimiters to oldDelim
return str
end GetString
on SetString(the_label, str)
set oldDelim to text item delimiters
set text item delimiters to kDelim & kDelim & the_label & kDelim
if ((count of text items in sData) = 3) then
set tempData to text items of sData
set item 2 of tempData to str
set sData to tempData as string
else
set sData to sData & kDelim & the_label & kDelim & str &
[NO-BREAK]kDelim & kDelim & the_label & kDelim
end if
set text item delimiters to oldDelim
return str
end SetString
end script
---------------------------------------------
copy LabeledStrings to numberList -- new LabeledStrings object
tell numberList
SetString("0", "2")
SetString("1", "1")
SetString("2", "12")
SetString("3", "40")
GetString("2")
end tell
======================================================================
[formatted using ScriptToEmail - gentle relief for mailing list pains]
[
http://files.macscripter.net/ScriptBuilders/ScriptTools/ScriptToEmail.hqx]
Very nice too, imho, as long as you're cool with the "strings only"
limitation and case-sensitive labels (which for lots of tasks won't be a
problem).
Should be real zippy too, since it's all TID-based. The only real speed hit
I think you might see will be as you add more and more new data. Every time
something is added to sData, the whole thing needs copied in memory (and
the bigger the string, the longer it takes to copy).
Oh, and here's a thought: with a little extra work you could enable it to
do "reverse" lookups as well, allowing you get a list of all labels whose
values match a given string. Might be handy...
>
P.S. I'm still just a scripter... ;-)
Sure, and Elvis was just a singer... ;)
has