function OcttoBin(i: integer): string;
//十进制转换为二进制字符串
var
j: integer;
s: string;
begin
j := i;
s := ' ';
while j >= 2do
begin
if (j mod 2) = 1 then
begin
s := '1' + s;
j := j div 2;
end
else
begin
s := '0' + s;
j := j div 2;
end;
end;
s := chr(ord('0') + j) + s;
result := s;
end;
function BintoOct(k: string): integer;
//二进制字符串转换为十进制
var
i, j, t: integer;
s: char;
begin
t := 1;
j := length(k);
j := 0 + (ord(k[j]) - ord('0')) * t;
;
for i := length(k) - 1do
wnto 1do
begin
s := k;
t := t * 2;
j := j + ((ord(s) - ord('0')) * t);
end;
result := j;
end;
function OcttoHex(i: integer): string;
//十进制转换为四位的十六进制字符串
begin
result := InttoHex(i, 4);
end;
function HextoOct(k: string): integer;
//十六进制字符串转换为十进制数
begin
result := StrtoInt('$' + k);
end;
function HextoBin(k: string): string;
//十六进制字符串转换为二进制字符串
begin
result := OcttoBin(HextoOct(k));
end;
function BintoHex(k: string): string;
//二进制字符串转换为四位的十六进制字符串
begin
result := Octtohex(BintoOct(k));
end;