function cn(CurrStr:string):Integer ;
var i,sum:Integer;
CurrChr:char;
begin
sum:=0;
for i:=1 to Length(CurrStr) do begin
CurrChr:=CurrStr[length(CurrStr)-i+1];
case CurrChr of
'0'..'9':sum:=sum+TRUNC(StrToInt(CurrChr)*intpower(16,i-1));
'a'..'f':sum:=sum+TRUNC((ord(CurrChr)-87)*intpower(16,i-1));
'A'..'F':sum:=sum+TRUNC((ord(CurrChr)-55)*intpower(16,i-1));
else begin
ShowMessage('Convert Error!');
result:=-1;
Exit;
end;
end;
end;
Result:=sum;
end;