Convert Decimal to Hex

This script converts whole(real) numbers to hexadecimal…

on ConvertToHex(ANumber)
set the hex_list to ¬
{“0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, ¬
“9”, “A”, “B”, “C”, “D”, “E”, “F”}

set thehex to ""
set this_number to ANumber
repeat while length of thehex is less than 4
	set remainder to (this_number mod 16)
	set this_number to (this_number - remainder) div 16
	set thechar to item (remainder + 1) of the hex_list
	set thehex to thechar & thehex
end repeat
return thehex

end ConvertToHex

in this form it will only do up to 65535, but if you change the repeat from less than 4 to however many digits you need… you get the idea

this is in no way meant to be a great script, but it does the job. I needed this to do some stuff with HD recording and changing the channel on a cable box via firewire…
http://www.macosxhints.com/article.php?story=20040426151111599