Originally Posted by

**colin**
I had to do somethign like that once, sending binaries to a program.

I used a function called IntToBin to get binary values, then set them...

function TServerMain.IntToBin(Value: LongInt; Digits: integer ): String;

begin

Result := StringOfChar ('0', Digits) ;

while Value > 0 do begin

if (Value and 1) = 1 then

Result[digits] := '1';

Dec(Digits);

Value := Value shr 1;

end;

end;

Should be easy enough to port to whatever language. Then you have a string of 1s and 0s that define your outputs. You could reverse it by changing

Result := StringOfChar ('0', Digits) ;

...

Result[digits] := '1';

to

Result := StringOfChar ('1', Digits) ;

..

Result[digits] := '0';

## Bookmarks