udfDecToHex (1)
str udfDecToHex (int)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfDecToHex (intDecimal, intPadLength)
arrHex = Arrayize ("0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F", ",")
strHex = ""
intZ = 0
For intI = 7 To 0 By -1
   intN = (intDecimal >> (intI << 2)) & 15
   If !intN Then If !intZ Then Continue
   intZ = intZ + 1
   strHex = strHex : arrHex [intN]
Next
Return StrFixLeft (strHex, "0", Min (8, Max (intZ, intPadLength)))
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

intNum = +25
strHex = udfDecToHex (intNum, 0) ; "19"
Message (intNum, strHex)

intNum = -25
strHex = udfDecToHex (intNum, 0) ; "FFFFFFE7"
Message (intNum, strHex)

intNum = 4078
strHex = udfDecToHex (intNum, 4) ; "0FEE"
Message (intNum, strHex)

Exit