Код
program clock_device;
{ (w) by Sergey Top <stop@stop.karaganda.su> }
{ CLOCK$ is a character device which handles device requests to input and }
{ output exactly 6 bytes. An input request should return 6 bytes indicating }
{ the current time/date and an output request should accept 6 bytes to set }
{ the clock/calendar. The format for CLOCK$ I/O is: }
type
clock = record
date:word; { days since Jan 1, 1980 }
min:byte; { current minute (0-59) }
hrs:byte; { current hour (0-24) }
hun:byte; { current 1/100 of second (0-99) }
sec:byte; { current second (0-59) }
end;
var
f:file of byte;
c:clock;
begin
Assign(f,'CLOCK$');
Reset(f);
read(f,byte(c.date));
Close(f);
writeln(c.hrs:2,':',c.min:2,' ',c.date:6);
end.
{ (w) by Sergey Top <stop@stop.karaganda.su> }
{ CLOCK$ is a character device which handles device requests to input and }
{ output exactly 6 bytes. An input request should return 6 bytes indicating }
{ the current time/date and an output request should accept 6 bytes to set }
{ the clock/calendar. The format for CLOCK$ I/O is: }
type
clock = record
date:word; { days since Jan 1, 1980 }
min:byte; { current minute (0-59) }
hrs:byte; { current hour (0-24) }
hun:byte; { current 1/100 of second (0-99) }
sec:byte; { current second (0-59) }
end;
var
f:file of byte;
c:clock;
begin
Assign(f,'CLOCK$');
Reset(f);
read(f,byte(c.date));
Close(f);
writeln(c.hrs:2,':',c.min:2,' ',c.date:6);
end.