|
This example program displays a digital clock on the text console
$ include "seed7_05.s7i"; # Standard Seed7 library
include "time.s7i"; # Import time and duration functions
include "keybd.s7i"; # Import the keypressed function
const proc: main is func
local
var time: next_time is time.value;
begin
writeln;
next_time := truncToSecond(time(NOW));
while not keypressed(KEYBOARD) do
next_time +:= 1 . SECONDS;
await(next_time);
write(next_time <& " \r");
flush(OUT);
end while;
writeln;
writeln;
end func;
This example uses time functions like 'time(NOW)' and 'await(next_time)'. There is an addition of a duration to a time and a time is written with 'write(next_time)'.
The program is terminated when a key is pressed. This check is done with the 'keypressed(KEYBOARD)' function.
|