Seed7 
 FAQ 
 Manual 
 Screenshots 
 Examples 
 Algorithms 
 Download 
 Links 

 Examples 
 echo args 
 declare stmt 
 template 
 operator 
 file in string 
 simple clock 
 count words 
 subtype 
 Examples 
Hello world
 previous   up   next 

A Seed7 program consists of a sequence of declarations. A declaration attaches a type and a name to the new object. In addition every new declared object gets an initial value.

Here is an example of a declaration:

 const proc: main is func
   begin
     writeln("hello world");
   end func;

The object 'main' is declared as constant. The type of 'main' is 'proc'. Declaring 'main' with the type 'proc' makes a procedure out of it. The object 'main' gets a

    func ... end func

construct as value. The 'func' construct is similar to begin ... end in PASCAL and { ... } in C. Inside the 'func' construct is a 'writeln' statement with the "hello world" string. The 'writeln' statement is used to write a string followed by a newline character. To use this declaration as the standard hello world example program, we have to include the standard library:

 $ include "seed7_05.s7i";

 const proc: main is func
   begin
     writeln("hello world");
   end func;

If you write this program in a file called world.sd7 and execute the command 'hi world' the Seed7 interpreter writes something like

 HI INTERPRETER Version 4.5.719  Copyright (c) 1990-2006 Thomas Mertes
    252 syntax.s7i
   2943 seed7_05.s7i
      6 world.sd7
   3201 lines total
  26875 lines per second
 1372331 bytes
 hello world

You get information about the Seed7 interpreter, a list of libraries included and how many lines they contain, the number of bytes used by the world.sd7 program and finally the output of the world.sd7 program itself:

 hello world


 previous   up   next