Aktualny czas

Aktualny czas

Program: Wyświetlający aktualną godzinę. (wersja graficzna)

Program korzystający z modułu graficznego, pobiera aktualną godzinę i co sekundę odświeża ekran, aż do naciśnięcia przycisku.

Kompilator: Turbo Pascal

Galeria:

Program w akcji.

Kod programu:

program czas;
uses crt,dos,graph;
const sciezka='c:\progra~1\tp\bgi';
var
   d,mode:integer;
   h,m,s,s100,r,mi,dz,dt:word;
   xs,ys:integer;
   hs,ms,ss,czas1,czas2:string;
   begin
   d:=detect;
   initgraph(d,mode,sciezka);
   if graphresult<>grOK then
   halt(1);
   xs:=getmaxx div 2;
   ys:=getmaxy div 2;
   settextstyle(defaultfont,horizdir,10);
   settextjustify(centertext,centertext);
   czas2:='';
   repeat
   getdate(r,mi,dz,dt);
         gettime(h,m,s,s100);
         str(h,hs);
         if length(hs)<2 then
         hs:='0'+hs;
         str(m,ms);
         if length(ms)<2 then
         ms:='0'+ms;
         str(s,ss);
         if length(ss)<2 then
         ss:='0'+ss;
         czas1:=hs+':'+ms+':'+ss;
         if czas1<>czas2 then
         begin
              setcolor(black);
              outtextxy(xs,ys,czas2);
              setcolor(red);
              outtextxy(xs,ys,czas1);
              czas2:=czas1;
              delay(100);
              end;
         until keypressed;
  closegraph;
end.