Re: Labels of a Record
Re: Labels of a Record
- Subject: Re: Labels of a Record
- From: has <email@hidden>
- Date: Tue, 6 Aug 2002 14:17:22 +0100
Mr Tea wrote:
>
Well, you could take a hammer to it...
>
>
set theTestList to {a:"b", c:3, d:"Jojo Bozo"}
>
try
>
theTestList as string
>
on error errmsg
>
set AppleScript's text item delimiters to ":"
>
set theChunks to every text item of errmsg
>
set AppleScript's text item delimiters to ""
>
set theLabelList to {}
>
repeat with theText in items 1 thru -2 of theChunks
>
set theLabelList to theLabelList & {character -1 of theText, ", "}
>
end repeat
>
end try
>
items 1 thru -2 of theLabelList as string
>
>
--> "a, c, d"
>
>
It's as rough as a bear's behind, but perhaps you can use it. ;-)
Oh, much, much rougher, I would say. (Though how would you know what a
bear's behind... oh, never mind...;)
There's a function for doing this in my ancient hashLib library which you
can dig up on ScriptBuilders. Be warned; it's not very fast.
You could use the RecordAccess osax, but this isn't available for OS X
which may be a problem for you.
The real problem is that records are not a good structure to use when you
need to manipulate keys. Alas, AS doesn't have a built-in hash (associative
array) type. (<sigh> Well, maybe one day; we can but live in hope...)
So your only options are to do horrid things to records (as above) or use
your own associative array objects. Various folk have written libraries for
the latter, including Arthur and myself. (You can find mine on my site,
<www.barple.connectfree.co.uk>.)
Though maybe if you could say why you need to extract labels in the first
place, maybe some other solution will spring to mind...
HTH
has
--
(My email address has changed from <email@hidden> to
<email@hidden>. Please update your address books accordingly.)
_______________________________________________
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.