• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reco Label Stringer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reco Label Stringer


  • Subject: Re: Reco Label Stringer
  • From: has <email@hidden>
  • Date: Sat, 27 Apr 2002 21:51:58 +0100

Michael Sullivan wrote:

>> I couldn't find anything I recognised as Arthur's 'TID-based pseudo-hash
>> script' though you mentioned posting it once.
>
>I think he's referring to AssociativeLib which is on www.applemods.com,
>though from the noise Arthur made in response to one of the recent
>mentions, the existing version may be a bit under his current speed
>tweaking and/or error checking, or just plain elegant programming
>abilities.

Nope, not that one - it stores keys in a list, so is slower. (Unless it's
been redone since its original release.)

Amazing what one can find lurking in the deep recesses of one's own hard
drive, however. Don't think Arthur will mind if I repost his [bug-fixed]
TID-based associative array code here.

I've never compared it directly against my own associativeArrayLib so don't
know how they compare performance-wise, but they should be pretty similar
(Arthur's may be a bit faster with small amounts of data as it's clean and
simple code, but mine should prove more efficient as the number of
key-values increases). If simple is good, use this. If your values aren't
strings or you need support for case-insensitive keys [1], use mine.
Arthur's associativeArray will be slower, but I think it supports keys of
any class, and case-sensitivity, etc. will be controllable via AS's
ignoring/considering keywords which is more flexible than my
case-insensitive implementation.

Cheers,

has

[1] Character set-dependent, unfortunately. Folk using non-MacRoman
character sets will have to tweak the thing to support their own character
set's high-ASCII characters correctly. (The same is true of stringLib, btw,
though it's better designed for expandability. This stuff is always a
problem; it'd be great if AS acquired some new features that'd make it
possible to get this sort of information from the system itself.)

======================================================================

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
--log {text items in sData}
if ((count of text items in sData) = 3) then
set str to text item 2 of sData
else
set text item delimiters to oldDelim
error "The label \"" & the_label & "\" does not exist."
[NO-BREAK]number 1
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", "22")

SetString("4", "6")
log numberList's sData

log GetString("2") --> "1654"

--log GetString("5")

end tell

======================================================================
[formatted using ScriptToEmail - gentle relief for mailing list pains]
[http://files.macscripter.net/ScriptBuilders/ScriptTools/ScriptToEmail.hqx]

--
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.

  • Follow-Ups:
    • Re: Reco Label Stringer
      • From: Andy Wylie <email@hidden>
  • Prev by Date: Re: How to calculate/process this one?
  • Next by Date: Fwd: Re: Exponential notation [was: Re: How to calculate/process this one?]
  • Previous by thread: Re: Reco Label Stringer
  • Next by thread: Re: Reco Label Stringer
  • Index(es):
    • Date
    • Thread