;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfDecToHex (intDecimal, intPadLength) arrHex = ArrayFromStr ("0123456789ABCDEF") 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))) ;.......................................................................................................................................... ; This udf "udfDecToHex" converts a decimal number to a hex number string, optional padded with leading zeroes. ; The newly introduced array function "ArrayFromStr(string)" accepts a text string and returns a one dimension array ; with one string character per array element. Minimum WinBatch version: WB 2010A January 27, 2010, DLL 6.10aja. ;.......................................................................................................................................... #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 ; (c)Detlev Dalitz.20100130.