$PBExportHeader$tohex.srf
global type tohex from function_object
end type

forward prototypes
global function string tohex (long arg_i, integer arg_len)
end prototypes

global function string tohex (long arg_i, integer arg_len);// 将arg_i转换成长度为arg_len的十六进制字符串，去掉溢出高位

char c[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}
string rslt = ''
long ll_tmp
do while arg_i >= 16
	ll_tmp = mod(arg_i, 16)
	rslt = c[ll_tmp + 1] + rslt
	arg_i = arg_i / 16
loop
rslt = c[arg_i + 1] + rslt
long rel_len
rel_len = len(rslt)
if rel_len > arg_len then
	rslt = right(rslt, arg_len)
else
	long i
	for i = 1 to (arg_len - rel_len)
		rslt = '0' + rslt
	next
end if
return rslt
end function

