@@ -5,10 +5,7 @@ package Streams "Read from files and write to files"
55 impure function print "Print string to terminal or file"
66 extends Modelica.Icons.Function;
77 input String string= "" "String to be printed" ;
8- input String fileName= ""
9- "File where to print (empty string is the terminal)"
10- annotation(Dialog(saveSelector(filter="Text files (*.txt)" ,
11- caption="Text file to store the output of print(..)" )));
8+ input String fileName= "" "File where to print (empty string is the terminal)" annotation(Dialog(saveSelector(filter="Text files (*.txt)" , caption="Text file to store the output of print(..)" )));
129 external "C" ModelicaInternal_print(string, fileName) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaInternal.h\"" , Library="ModelicaExternalC" );
1310 annotation (Documentation(info="<html>
1411<h4>Syntax</h4>
@@ -45,11 +42,9 @@ Streams.print(\"x = \" + String(y), \"mytestfile.txt\");
4542 impure function readFile
4643 "Read content of a file and return it in a vector of strings"
4744 extends Modelica.Icons.Function;
48- input String fileName "Name of the file that shall be read"
49- annotation(Dialog(loadSelector(filter="Text files (*.txt)" ,
50- caption="Open text file for reading" )));
45+ input String fileName "Name of the file that shall be read" annotation(Dialog(loadSelector(filter="Text files (*.txt)" , caption="Open text file for reading" )));
5146 output String stringVector[countLines(fileName)] "Content of file" ;
52- external "C" ModelicaInternal_readFile(fileName,stringVector,size (stringVector,1 )) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaInternal.h\"" , Library="ModelicaExternalC" );
47+ external "C" ModelicaInternal_readFile(fileName,stringVector,size (stringVector,1 )) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaInternal.h\"" , Library="ModelicaExternalC" );
5348 annotation (Documentation(info="<html>
5449<h4>Syntax</h4>
5550<blockquote><pre>
@@ -67,14 +62,11 @@ Note, a fileName can be defined as URI by using the helper function
6762
6863 impure function readLine "Read a line of text from a file and return it in a string"
6964 extends Modelica.Icons.Function;
70- input String fileName "Name of the file that shall be read"
71- annotation(Dialog(loadSelector(filter="Text files (*.txt)" ,
72- caption="Open text file for reading" )));
65+ input String fileName "Name of the file that shall be read" annotation(Dialog(loadSelector(filter="Text files (*.txt)" ,caption="Open text file for reading" )));
7366 input Integer lineNumber(min = 1 ) "Number of line to read" ;
7467 output String string "Line of text" ;
75- output Boolean endOfFile
76- "If true, end-of-file was reached when trying to read line" ;
77- external "C" string= ModelicaInternal_readLine(fileName,lineNumber,endOfFile) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaInternal.h\"" , Library="ModelicaExternalC" );
68+ output Boolean endOfFile "If true, end-of-file was reached when trying to read line" ;
69+ external "C" string= ModelicaInternal_readLine(fileName,lineNumber,endOfFile) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaInternal.h\"" , Library="ModelicaExternalC" );
7870 annotation (Documentation(info="<html>
7971<h4>Syntax</h4>
8072<blockquote><pre>
@@ -97,10 +89,7 @@ and endOfFile=true. Otherwise endOfFile=false.
9789
9890 impure function countLines "Return the number of lines in a file"
9991 extends Modelica.Icons.Function;
100- input String fileName "Name of the file that shall be read"
101- annotation(Dialog(loadSelector(filter="Text files (*.txt)" ,
102- caption="Open text file for counting lines" )));
103-
92+ input String fileName "Name of the file that shall be read" annotation(Dialog(loadSelector(filter="Text files (*.txt)" , caption="Open text file for counting lines" )));
10493 output Integer numberOfLines "Number of lines in file" ;
10594 external "C" numberOfLines= ModelicaInternal_countLines(fileName) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaInternal.h\"" , Library="ModelicaExternalC" );
10695 annotation (Documentation(info="<html>
@@ -120,7 +109,8 @@ separated by LF or CR-LF.
120109 pure function error "Print error message and cancel all actions - in case of an unrecoverable error"
121110 extends Modelica.Icons.Function;
122111 input String string "String to be printed to error message window" ;
123- external "C" ModelicaError(string) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaUtilities.h\"" , Library="ModelicaExternalC" );
112+ algorithm
113+ assert (false , string, AssertionLevel.error);
124114 annotation (Documentation(info="<html>
125115<h4>Syntax</h4>
126116<blockquote><pre>
@@ -149,19 +139,16 @@ Streams.error(\"x (= \" + String(x) + \")\\nhas to be in the range 0 .. 1\");
149139
150140 impure function close "Close file"
151141 extends Modelica.Icons.Function;
152- input String fileName "Name of the file that shall be closed"
153- annotation(Dialog(loadSelector(filter="Text files (*.txt)" ,
154- caption="Close text file" )));
155- external "C" ModelicaStreams_closeFile(fileName) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaInternal.h\"" , Library="ModelicaExternalC" );
142+ input String fileName "Name of the file that shall be closed" annotation(Dialog(loadSelector(filter="Text files (*.txt)" , caption="Close text file" )));
143+ external "C" ModelicaStreams_closeFile(fileName) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaInternal.h\"" , Library="ModelicaExternalC" );
156144 annotation (Documentation(info="<html>
157145<h4>Syntax</h4>
158146<blockquote><pre>
159147Streams.<strong>close</strong>(fileName)
160148</pre></blockquote>
161149<h4>Description</h4>
162150<p>
163- Close file if it is open. Ignore call if
164- file is already closed or does not exist.
151+ Close file if it is open. Ignore call if file is already closed or does not exist.
165152</p>
166153</html>" ));
167154 end close;
@@ -171,7 +158,7 @@ file is already closed or does not exist.
171158 input String fileName "File where external data is stored" annotation(Dialog(loadSelector(filter="MATLAB MAT files (*.mat)" , caption="Open MATLAB MAT file" )));
172159 input String matrixName "Name / identifier of the 2D Real array on the file" ;
173160 output Integer dim[2 ] "Number of rows and columns of the 2D Real array" ;
174- external "C" ModelicaIO_readMatrixSizes(fileName, matrixName, dim)
161+ external "C" ModelicaIO_readMatrixSizes(fileName, matrixName, dim)
175162 annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaIO.h\"" , Library={"ModelicaIO" , "ModelicaMatIO" , "zlib" });
176163 annotation(Documentation(info="<html>
177164<h4>Syntax</h4>
@@ -206,10 +193,9 @@ See <a href=\"modelica://Modelica.Utilities.Examples.ReadRealMatrixFromFile\">Ex
206193 input String matrixName "Name / identifier of the 2D Real array on the file" ;
207194 input Integer nrow "Number of rows of the 2D Real array" ;
208195 input Integer ncol "Number of columns of the 2D Real array" ;
209- input Boolean verboseRead = true
210- "= true: Print info message; = false: No info message" ;
196+ input Boolean verboseRead = true "= true: Print info message; = false: No info message" ;
211197 output Real matrix [nrow, ncol] "2D Real array" ;
212- external "C" ModelicaIO_readRealMatrix(fileName, matrixName, matrix , size (matrix , 1 ), size (matrix , 2 ), verboseRead)
198+ external "C" ModelicaIO_readRealMatrix(fileName, matrixName, matrix , size (matrix , 1 ), size (matrix , 2 ), verboseRead)
213199 annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaIO.h\"" , Library={"ModelicaIO" , "ModelicaMatIO" , "zlib" });
214200 annotation(Documentation(info="<html>
215201<h4>Syntax</h4>
@@ -251,10 +237,9 @@ See <a href=\"modelica://Modelica.Utilities.Examples.ReadRealMatrixFromFile\">Ex
251237 choice="6" "MATLAB v6 MAT file" ,
252238 choice="7" "MATLAB v7 MAT file" ));
253239 output Boolean success "true if successful" ;
254- external "C" success = ModelicaIO_writeRealMatrix(fileName, matrixName, matrix , size (matrix , 1 ), size (matrix , 2 ), append, format)
240+ external "C" success = ModelicaIO_writeRealMatrix(fileName, matrixName, matrix , size (matrix , 1 ), size (matrix , 2 ), append, format)
255241 annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources" , Include="#include \" ModelicaIO.h\"" , Library={"ModelicaIO" , "ModelicaMatIO" , "zlib" });
256242 annotation(Documentation(info="<html>
257-
258243<h4>Syntax</h4>
259244<blockquote><pre>
260245success = Streams.<strong>writeRealMatrix</strong>(fileName, matrixName, matrix, append, format)
0 commit comments