Examples |
|
Simple clock |
|
This example program displays a digital clock on the text console
$ include "seed7_05.s7i"; # Standard Seed7 library include "time.s7i"; # Import time functions include "duration.s7i"; # Import duration functions include "keybd.s7i"; # Import the function inputReady const proc: main is func local var time: next_time is time.value; begin writeln; next_time := truncToSecond(time(NOW)); while not inputReady(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), truncToSecond and await(next_time). There is an addition of a duration to a time with +:= and a time is written with 'write(next_time)'.
The program is terminated if a key is pressed. This check is done with the inputReady(KEYBOARD) function.
|
|