Re: interesting discovery (trying to get record labels as strings)
Re: interesting discovery (trying to get record labels as strings)
- Subject: Re: interesting discovery (trying to get record labels as strings)
- From: Arthur J Knapp <email@hidden>
- Date: Mon, 03 Dec 2001 13:15:57 -0500
>
Date: Sun, 2 Dec 2001 18:23:16 +0000
>
From: has <email@hidden>
>
Subject: interesting discovery (trying to get record labels as strings)
>
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.
OH MY GOSH!!!
has, I have been looking for a vanilla way to do this for years, AND
YOU FOUND IT!!!
How is it that I have never seen this before? It is so frustrating!!!
>
... 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.)
It works on every OS we have in the office!!!
>
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"})
Yes, fantastic.
>
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.)
Thank you for such a nice Christmas gift... ;-)
I have so many ideas for this, I don't even know where to start.
This will have to do for now:
on IntegerToBytes(n)
return ({{_:n}} as string)'s text -4 thru -1
end IntegerToBytes
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://www.natural-innovations.com/as/>
on error number -128
end try
}