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: Tue, 04 Dec 2001 10:56:10 -0500
>
Date: Tue, 4 Dec 2001 01:14:08 +0000
>
From: has <email@hidden>
>
Subject: Re: interesting discovery (trying to get record labels as
>
strings)
>
Arthur J Knapp wrote:
>
> OH MY GOSH!!!
>
> Thank you for such a nice Christmas gift... ;-)
>
Um... hey, you're welcome. (Wow, I wish my family was as easy to shop for
>
as Arthur is...;)
>
... I've got plenty of other things more pressing to be
>
getting on with - but do feel free to play with it yourself.
OK. :)
This needs to be rewritten a little more intuatively, but it
works:
property k0 : ASCII character 0
property k1 : ASCII character 1
property k2 : ASCII character 2
property k4 : ASCII character 4
property k0000 : k0 & k0 & k0 & k0
property k0001 : k0 & k0 & k0 & k1
property k0002 : k0 & k0 & k0 & k2
property k0004 : k0 & k0 & k0 & k4
on IntegerToBytes(n)
return ({{a:n}} as string)'s text -4 thru -1
end IntegerToBytes
on StringToCodes(str)
set o to text item delimiters
try
set str to str's items -- length must be < approx 4050
set itemCount to IntegerToBytes(str's length)
set typeStr to "long" & k0004 & k0 & k0 & k0
set text item delimiters to {typeStr}
set str to typeStr & str
set str to itemCount & k0000 & str
set str to "list" & IntegerToBytes(str's length) & str
set str to k0002 & k0000 & "TEXT" & k0001 & "a" & k0 & str
set str to IntegerToBytes(str's length) & str
set str to k0001 & k0000 & "usrflist" & str
on error m number n
set text item delimiters to o
error m number n
end try
set o to text item delimiters
return a of (str as record)
end StringToCodes
StringToCodes("Hello World")
--
--> {72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100}
Try performing ascii conversions this quickly with the ASCII
commands from Standard Additions... ;-)
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://homepage.mac.com/ewalet/DeskTop.html>
on error number -128
end try
}