Seed7 
 FAQ 
 Manual 
 Screenshots 
 Examples 
 Algorithms 
 Download 
 Links 

 Examples 
 echo args 
 declare stmt 
 template 
 operator 
 file in string 
 simple clock 
 count words 
 subtype 
 Examples 
Echo the program arguments
 previous   up   next 

This example program writes its arguments

 $ include "seed7_05.s7i";       # Standard Seed7 library

 const proc: main is func
   local
     var string: stri is "";
   begin
     for stri range argv(PROGRAM) do
       write(stri <& " ");
     end for;
     writeln;
   end func;

Everything between # and the end of the line is a comment which is ignored.

The keyword 'local' introduces local declarations. In this case the string variable 'stri' is declared and initialized with an empty string ("").

The 'argv(PROGRAM)' function returns the program arguments as array of strings. The 'for' loop iterates over all elements of this array. The 'for' statement is overloaded for various collection types.

The '<&' operator is used to concatenate elements before writing. If one operand of the '<&' operator has not the type 'string' it is converted to a 'string' using the 'str' function.


 previous   up   next