Function BinStrToInt(BinStr: String): integer;
Var
counter: integer;
Function pow(base, power: integer): integer;
Var
counter: integer;
begin
Result := 1;
For counter := 1 To powerdo
Result := Result * base;
end;
begin
If length(BinStr) > 16 then
Raise ERangeError.Create(#13 + BinStr + #13 +
'is not within the valid range of a 16 bit binary.' + #13);
Result := 0;
For counter := 1 To length(BinStr)do
If BinStr[Counter] = '1' then
Result := Result + pow(2, length(BinStr) - counter);
end;