Re: Hex String Handlers
Re: Hex String Handlers
- Subject: Re: Hex String Handlers
- From: Gnarlodious <email@hidden>
- Date: Fri, 27 Dec 2002 08:57:52 -0700
Entity Hudson Barton spoke thus:
>
I have a little routine to convert an ascii string into its hex
>
equivalent, and another to reverse the process. It is very slow on
>
anything but the smallest text segment
Here is what I am running, credits to Kai Edwards for the speed:
on hexToRGB(tx)
set {tid, tx, hx, lC, rgb} to ,
{text item delimiters, tx's text -6 thru -1, "0123456789ABCDEF",
"abcdef", {}}
repeat with n from 1 to 6 by 2
set col to 0
repeat with x from 0 to 1
set char to tx's character (n + x)
tell 1 - x to set num to 16 ^ it + 16 ^ (it + 2)
considering case
if char is in lC then set char to ASCII character ((ASCII
number char) - 32)
end considering
set text item delimiters to char
set col to col + (hx's text item 1's length) * num
end repeat
set rgb's end to col
end repeat
set text item delimiters to tid
rgb
end hexToRGB
Hope that makes sense . . .
-- Rachel
http://www.Spectrumology.com
AIM Gnarlodious
_______________________________________________
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.