Opened 9 years ago

Last modified 9 years ago

#3953 new defect

simulate(..) returns record instead of string — at Version 4

Reported by: Bernhard Thiele Owned by: somebody
Priority: high Milestone: Future
Component: Interactive Environment Version:
Keywords: Cc: Adrian Pop, Martin Sjölund

Description (last modified by Bernhard Thiele)

According the its signature the MOS scripting function simulate(..) should return a String. However, (?sometimes?) a record is returned.

Consider following MOS script:

loadModel(Modelica);

res := simulate(Modelica.Blocks.Examples.PID_Controller);
print("A");
print(res); // No error, but this line will be blank?
print("B");

if true then
  res := simulate(Modelica.Blocks.Examples.PID_Controller);
  print(res); // Throws an error that a record is passed, but a String is expected
else
  print("Just to have an else");
end if;

The first print doesn't work (but throws no error), the second print fails with a type error (expected String, but got a record).

How is the return value of simulate(..) supposed to work?

Change History (5)

by Bernhard Thiele, 9 years ago

Attachment: runSimulate.mos added

The mos script calling simulate(..)

comment:1 by anonymous, 9 years ago

It is supposed to be a record that is passed. If the ModelicaBuiltin.mo says otherwise, that is an error.

comment:2 by Bernhard Thiele, 9 years ago

OK. I just finished a commit that would change the return value to a String (https://github.com/OpenModelica/OMCompiler/pull/953).

However, I'm also fine with a record, which would mean that the signature should be fixed.

Some of the record fields are created dynamically in CevalScriptBackend.createSimulationResult(..). If one was to fix the signature, I suppose one will need a static record type for the return value?

comment:3 by Martin Sjölund, 9 years ago

I think the full record should always be created, but when doing ValuesUtil.valString to show the value in the mos-script it should filter out the fields that are not testsuite-friendly.

comment:4 by Bernhard Thiele, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.