Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

how to use Openmodelica Scripting to delete multiple files

how to use Openmodelica Scripting to delete multiple files

Hallo, every one,

now I use openmodelica Scripting in oder to simulate a Model with different Parameters. It worked. but during the simulation OM creats a lot of Intermediate Files, which is very in convienient. In OM Connection editor, in Tools->Option->Simulation there is a Option "delete intermediate Compilation files". When it is choosed, OMC will automatically delete the Intermediate files. However in Openmodelica Scripting I only find a function "deleteFiles", that can only delelte a file at once.
Is there a way to solve this?

best regards

Re: how to use Openmodelica Scripting to delete multiple files

Call /bin/rm to remove some files?

Re: how to use Openmodelica Scripting to delete multiple files

I add /bin/rm to my code, but it does not word. Here is my Code
-----------------------------------------------------------------------------------------
cd("C:\Users\USERNAME\Desktop\Modelica_Uebung\ParameterSweep\TestModels");
//loadFile("package.mo");
//loadFile("Model.mo");
getErrorString();
str_model := "RefrigerationCycle_Demo.Simple_Cycle_SL.Tests.Test_Cycle";
simulate(RefrigerationCycle_Demo.Simple_Cycle_SL.Tests.Test_Cycle);
//stringTypeName(str_model);
//simulate(stringTypeName(str_model));
getErrorString();

for p in {926901, 956901, 986901, 1036901, 1066901} loop
  str_p := String(p);
  getErrorString();
  //str_cmd := str_model + ".exe -override a=" + str_a;
  //print(str_cmd + "\n");
  //getErrorString();
  //system(str_cmd, "output.txt");
  //system("RefrigerationCycle_Demo.Simple_Cycle_2.Tests.test_Cycle.exe -override RefrigerationCycle_Demo.Simple_Cycle_2.Tests.test_Cycle.simpleHeatExchanger_m_dot.p_ex=" + String(p) + " -r=Model_" + String(p) + "_res.mat");
  system(str_model + ".exe -override Kondensator.p_ex=" + String(p) + " -r=Model_" + String(p) + "_res.mat");
  getErrorString();
  //res := readSimulationResult("Model_res.mat", x); getErrorString();
  //results := results + str_a + "," + String(res[size(res, 1), size(res, 2)]) + ",\n";
  //closeSimulationResultFile();
end for;
#!/bin/bash
rm *.o;
rm *.c;
rm *.h;

Re: how to use Openmodelica Scripting to delete multiple files

Instead of this:

Code:


#!/bin/bash
rm *.o;
rm *.c;
rm *.h;

do:

Code:


system("rm -f *.o *.c *.h");

Re: how to use Openmodelica Scripting to delete multiple files

Thanks, it worked!

There are 0 guests and 0 other users also viewing this topic
You are here: