function Hex2Dec(Hexs: string): string;
var
i,j: integer;
res,base: LongWord;
begin
res := 0;
for i:=1 to Length(Hexs) do
begin
base := 1;
for j:=1 to Length(Hexs)-i do
base := base * 16;
case Hexs of
'0'..'9': res := res + (Ord(Hexs) - Ord('0')) * base;
'a'..'f': res := res + (Ord(Hexs) - Ord('a') + 10) * base;
'A'..'F': res := res + (Ord(Hexs) - Ord('A') + 10) * base;
end;
end;
result := inttostr(res);
end;
function BcdToHex(Hexstr: string): string;
var
i: integer;
returnstr : string;
begin
result := '0';
try
returnstr := IntToHex(StrToInt64(Hexstr),4);
for i := 1 to length(returnstr) do
begin
if returnstr[1] = '0' then
delete(returnstr,1,1);
end;
Result := returnstr;
except
end;
end;