another way, works for 0 <= n <= 256 , expandable.

on d2h d
   return rgb(0,0,d).hexstring().char[6..7]
end

on h2d h
   return rgb("#0000"&h).blue
end

best regards
daniel plaenitz



At 09:49 17.01.2001 +0900, Fumio Nonaka wrote:
>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


[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!]

Reply via email to