Examples |
|
Echo the program arguments |
|
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 "", the empty string literal.
The function argv(PROGRAM) returns the program arguments as array of strings. The 'for' (for-each) loop iterates over all elements of this array. The for-each 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.
|
|