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 string literal "hello world". 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 's7 world' the Seed7 interpreter writes something like

SEED7 INTERPRETER Version 5.0.4  Copyright (c) 1990-2013 Thomas Mertes
hello world

You get information about the Seed7 interpreter and the output of the world.sd7 program:

hello world


 previous   up   next