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; input String fileName "Name of file" annotation( Dialog(loadSelector(filter = "Text files (*.txt)", caption = "Open file in which Real parameters are present"))); input String name "Name of parameter"; output Real result "Actual value of parameter on file"; end readRealParameter;