this slowpoke moves

Draw String Binary Clock

function IntToBin(D: Longint): string;
var
  X: Integer;
  Bin: string;
  Tam : Integer;
Begin
  bin := '';
  If D = 0 then
     Tam := 8
     Else
     Tam := 8 * SizeOf(d);

  For x := 1 to Tam do
  Begin
    if Odd(d) then
       bin := '1' + bin
       else
       bin := '0' + bin;
  d := d shr 1;
  End;
  Delete(bin, 1, 8 * ((Pos('1', bin) - 1) div 8));
  Result := bin;
end;
{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var
Str : String;
Hour, Min, Sec : Integer;
begin
     Str := TimeToStr(Time);

     Hour := StrToInt(Copy(Str,1,2));
     Min := StrToInt(Copy(Str,4,2));
     Sec := StrToInt(Copy(Str,7,3));
     // recive 'binary' string
     Label1.caption := IntToBin(Hour) + ':'
     + IntToBin(Min) + ':' + IntToBin(Sec);

     // this label is for the others 01 people who don't

     Label2.Caption := Str;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate