• 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
interesting discovery (trying to get record labels as strings)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

interesting discovery (trying to get record labels as strings)


  • Subject: interesting discovery (trying to get record labels as strings)
  • From: has <email@hidden>
  • Date: Sun, 2 Dec 2001 18:23:16 +0000

Hi,

So I reckon by now there's some folks getting familiar with my funky new
hashLib, now the damn thing is finally out. And they might also have
noticed that the getRecordLabels() handler, used by convertRecordToList(),
fairly stinks for speed.

I've been hunting around for a while looking for a faster method, and now
I've run into something rather interesting in AS. No doubt it's a bug and
as such should really be plugged, but it's rather caught my eye all the
same...

Now, everyone knows that you can't coerce a record to string by doing:

{a:1} as string

This just throws an error, as you'd expect. However, try this:

{{a:1}} as string

and the results are _much_ more interesting. Try it and see. (Though if it
doesn't generate a lot of seemingly nonsensey stuff, let me know what
version of AS you're on [I'm on 1.3.7] as there's not much point pursuing
this if it won't work everywhere.)


So anyway, now I've gotten as far as the following:

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

on getTheDelimiter()
set theDelimiter to ""
repeat with eachChar in {92, 30, 9, 120, 8, 192, 9, 120, 8, 192,
[NO-BREAK]8, 192, 3, 166}
set theDelimiter to theDelimiter & (ASCII character eachChar)
end repeat
theDelimiter
end getTheDelimiter

property theDelimiter : getTheDelimiter()

on crunchTheRecord(theRecord)
set theList to {theRecord}
set theString to theList as string
set theString to text 2 thru -2 of (display result)
set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to theDelimiter
set newString to theString's text items
set AppleScript's text item delimiters to oldTID
items 19 thru -1 of newString
end crunchTheRecord

crunchTheRecord({myLabel:"hello world"})

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


That's a very select example, and it'd need a fair bit more work to come up
with something smart and robust enough to be useable. But it might be a
start.

So... anyone got any comments/feedback/info? (Would be much appreciated.)

Cheers,

has


  • Follow-Ups:
    • Re: interesting discovery (trying to get record labels as strings)
      • From: Chris Nebel <email@hidden>
  • Prev by Date: Re: Akua Time Form?
  • Next by Date: Filling forms in internet explorer
  • Previous by thread: Re: Jon's Commands Reference
  • Next by thread: Re: interesting discovery (trying to get record labels as strings)
  • Index(es):
    • Date
    • Thread