gfan
gfan

Reputation: 47

Getting a "Missing token: ASSIGN" error when running OpenModelica script through a batch file

I am trying to run an OpenModelica script using a DOS .bat file. But facing some issues. The batch file runmodelica.bat has

%OPENMODELICAHOME%\bin\omc testscript.mos

The file testscript.mos is

loadModel(Modelica)
getErrorString()
loadFile("HelloWorld.mo")
simulate(HelloWorld)
getErrorString()

If I run the commands in the testscript.mos file from an OM Shell by changing to that directory, everything works fine. But If I run the batch file from the DOS prompt, I get the following error

Error processing file: testscript.mos
[C:/Users/blahblah/testscript.mos:2:1-2:1:writable] Error: Missing token: ASSIGN

# Error encountered! Exiting...
# Please check the error message and the flags.

Execution failed!

The HelloWorld.mo file comes with the standard installation and I haven't modified it

class HelloWorld
  Real x(start = 1);
  parameter Real a = 1;
equation
  der(x) = - a * x;
end HelloWorld;

I am new to OpenModelica and searched online but couldn't find a solution. Any help is appreciated.

All the commands run in the OM Shell but not when invoked from the bat file.

Upvotes: 0

Views: 240

Answers (1)

Adrian Pop
Adrian Pop

Reputation: 4231

The script code needs to be valid Modelica, so you need ; after each command.

loadModel(Modelica);
getErrorString();
loadFile("HelloWorld.mo");
simulate(HelloWorld);
getErrorString();

Upvotes: 2

Related Questions