Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Examples echo args file in string simple clock count words subtype map function generic func declare stmt template operator 3-way if
Examples
Simple clock
 previous   up   next 

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 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), 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 when a key is pressed. This check is done with the keypressed(KEYBOARD) function.


 previous   up   next