- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » debugging .mos script
debugging .mos script
debugging .mos script
Is there a way to debug .mos scripts / their execution more efficiently?
I'm running them from OMShell, but if there is an error in the script it just says "fail", which is not very helpfull at all.
Just now i had a self defined assert (that i had forgotten about) in the model trigger for one of the parameters, and i was mistakenly looking inside the script itself for the failure ...
Re: debugging .mos script
Call getErrorString() to get messages
- sjoelund.se
- 1700 Posts
Re: debugging .mos script
sjoelund.se wrote:
Call getErrorString() to get messages
I already had getErrorString(); behind every line in the script, it doesnt seem to do much.
Code:
loadFile("model.mo");
getErrorString();
buildModel(model);
getErrorString();
system("model");
getErrorString();
just produces "failed" for me, if the model asserts. Calling it after i get "Failed" also produces nothing.
Re: debugging .mos script
Are you on a Windows OS?
I remember, that the last time I tried system didn't return any output on Windows, at least from mingw shell.
You have to add an output file to get the output of the system command.
See system from the Scripting API.
Similar to system(3). Executes the given command in the system shell.
impure function system
input String callStr "String to call: sh -c $callStr";
input String outputFile = "" "The output is redirected to this file (unless already done by callStr)";
output Integer retval "Return value of the system call; usually 0 on success";
end system;
For your example you probably want to do something like:
Code:
system("./model", "outPutFile.log"); getErrorString();
PS: There is a function to read files called readFile.
- AnHeuermann
- 52 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » debugging .mos script