result = readRealParameter(fileName, name);
This function demonstrates how a function can be implemented that reads the value of a parameter from file. The function performs the following actions:
On file "test.txt" the following lines might be present:
// Motor data J = 2.3 // inertia w_rel0 = 1.5*2; // relative angular velocity phi_rel0 = pi/3
The function returns the value "3.0" when called as:
readRealParameter("test.txt", "w_rel0")
function readRealParameter extends Modelica.Icons.Function; import Modelica.Utilities.*; import KeyWordIO; input String fileName "Name of file" annotation( Dialog(loadSelector(filter = "Data file (*.txt;*.dat)", caption = "Open text file for reading"))); input String name "Name of parameter"; input Boolean cache = false "Read file before compiling, if true"; output Real result "Actual value of parameter on file"; end readRealParameter;