|
program Esempio;
uses crt, dos, windows;
type
time=record
h,min,sec,s100 : word;
end;
var
T : time;
x, y : byte;
MessageThread1,MessageThread2 : Handle;
MessageID1,MessageID2 : DWord;
oraattivo, lampeggioattivo, scrivendo :boolean;
ris1, ris2 : word;
function orologio(p:pointer):Dword;stdcall;
begin
sleep(1);
oraattivo := true;
repeat
repeat sleep(1) until not(scrivendo);
x := wherex;
y := wherey;
gotoxy(69,1);
textcolor(15);
textbackground(0);
write(space(13));
gotoxy(69,1);
with t do begin
gettime(h,min,sec,s100);
write(h,':',min,':',sec,',',s100);
end;
gotoxy(x,y);
sleep(2);
until not(oraattivo);
orologio:=0;
end;
function lampeggio(p:pointer):Dword;stdcall;
begin
sleep(1);
lampeggioattivo:=true;
repeat
repeat sleep(1) until not(scrivendo);
scrivendo:=true;
sleep(1);
x := wherex;
y := wherey;
textcolor(10);
gotoxy(10,3);
write('Esempio');
gotoxy(x,y);
scrivendo:=false;
sleep(500);
repeat sleep(1) until not(scrivendo);
scrivendo:=true;
sleep(1);
x := wherex;
y := wherey;
textcolor(14);
gotoxy(10,3);
write('Esempio');
gotoxy(x,y);
scrivendo:=false;
sleep(500);
until not(lampeggioattivo);
lampeggio:=0;
end;
BEGIN
clrscr;
gotoxy(1,5);
MessageThread1:=CreateThread(nil,0,@orologio,nil,0,MessageID1);
repeat
GetExitCodeThread(MessageThread1,@ris1);
until oraattivo or (ris1<>STILL_ACTIVE);
MessageThread2:=CreateThread(nil,0,@lampeggio,nil,0,MessageID2);
repeat
GetExitCodeThread(MessageThread2,@ris2);
until lampeggioattivo or (ris2<>STILL_ACTIVE);
readln;
scrivendo:=true;
sleep(5);
gotoxy(2,5);
textcolor(15);
writeln('schiaccia un tasto');
scrivendo:=false;
repeat delay(1) until keypressed;
END.
|
|