impure functionprint

Print string to terminal or file

Extends from Modelica.Icons.Function (Icon for functions).

Information

Syntax

Streams.print(string);
Streams.print(string,fileName);

Description

Function print(..) opens automatically the given file, if it is not yet open. If the file does not exist, it is created. If the file does exist, the given string is appended to the file. If this is not desired, call "Files.remove(fileName)" before calling print ("remove(..)" is silent, if the file does not exist). The Modelica environment may close the file whenever appropriate. This can be enforced by calling Streams.close(fileName). After every call of "print(..)" a "new line" is printed automatically.

Example

Streams.print("x = " + String(x));
Streams.print("y = " + String(y));
Streams.print("x = " + String(y), "mytestfile.txt");

See also

Streams, Streams.error, ModelicaReference.Operators.'String()'

Inputs

TypeNameDefaultDescription
Stringstring""String to be printed
StringfileName""File where to print (empty string is the terminal)