Another code:
on xDecToHex nDec
nDec = integer(nDec)
if nDec < 0 then return void
if nDec = 0 then return "0"
sHexNums = "0123456789ABCDEF"
repeat while nDec
sNum = sHexNums.char[(nDec mod 16) + 1]
sResult = sNum & sResult
nDec = nDec / 16
end repeat
return sResult
end
_____
Laurent Brigaut wrote:
> Bad news: you have to write the code for it! Here is a small handler that
> works for integers >= 0 and <= the maxinteger:
>
> on IntegerToHex theint
> lMaxPower = 7
>
> lHexValue = ""
> lRest = theInt
> repeat with i = lMaxPower down to 0
> lTime = lRest/integer(power(16,i))
>
> if (lTime > 0) or (lHexValue <> "") then
> if (lTime > 9) then
> lHexValue = lHexValue & numtochar(chartonum("A") + lTime - 10)
> else
> lHexValue = lHexValue & string(lTime)
> end if
>
> lRest = lRest - lTime*integer(power(16,i))
> end if
> end repeat
>
> if lHexValue = "" then lHexValue = "0"
>
> return lHexValue
> end
Good luck,
Fumio Nonaka
Attain Corporation
Phone: +81-3-3255-4941
Fax: +81-3-3255-5998
mailto:[EMAIL PROTECTED]
http://www.attainj.co.jp
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]
- RE: <lingo-l> Converting String to Hex code Laurent Brigaut
- Re: <lingo-l> Converting String to Hex code Fumio Nonaka
- Re: <lingo-l> Converting String to Hex code Daniel Plaenitz
