RE: Need to translate IP addresses from hex value to dotted quad?
RE: Need to translate IP addresses from hex value to dotted quad?
- Subject: RE: Need to translate IP addresses from hex value to dotted quad?
- From: Richard 23 <email@hidden>
- Date: Sat, 17 Mar 2001 08:05:37 -0800
I could've sworn I sent something about this but didn't see it in my
sent mail... This kind of data translation is almost worth dusting
off the slide rule and putting on the propellorhead beanie hat.
Well almost.
If you don't mind performing coercions with Programmer's Tool, the
following will do it:
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d5
-- ---------------------------------------------------------
-- author: Richard 23, date: Saturday, March 17, 2001
-- ---------------------------------------------------------
-- requires Programmer's Tool osax
--
http://homepage.mac.com/richard23/applescript04.html#ProgrammersTool
-- ---------------------------------------------------------
HexToIp("D867DB2D")
--> "216.103.219.45"
on HexToIp(theStr)
cast {theStr} to "HEXD"
cast result using template "DBYT"
return Join(result, ".")
end HexToIp
on Join(theList, theDelim)
set {AppleScript's text item delimiters} to {theDelim}
set {AppleScript's text item delimiters} to {"", theList as string}
return result's end
end Join
-- ---------------------------------------------------------
the first cast coerces the string to data (string just looks like hex!),
the second cast coerces the hex data to a list of decimal bytes.
R23