home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
OL.LZH
/
PROCS.LZH
/
HEXCVT.ICN
< prev
next >
Wrap
Text File
|
1991-07-13
|
967b
|
43 lines
############################################################################
#
# Name: hexcvt.icn
#
# Title: Hexadecimal conversion
#
# Author: Robert J. Alexander
#
# Date: November 8, 1990
#
############################################################################
#
# hex(s) -- Converts string of hex digits into an integer.
#
#
# hexstring(i) -- Returns a string that is the hexadecimal
# representation of the argument.
#
############################################################################
procedure hex(s)
local a,c
a := 0
every c := !map(s) do
a := ior(find(c,"0123456789abcdef") - 1,ishift(a,4)) | fail
return a
end
procedure hexstring(i,n)
local s
i := integer(i) | fail
if i = 0 then s := "0"
else {
s := ""
while i ~= 0 do {
s := "0123456789ABCDEF"[iand(i,15) + 1] || s
i := ishift(i,-4)
}
}
if \n > *s then s := right(s,n,"0")
return s
end