Search code examples
migrationmodelicadymola

Conditional migration of a class in Dymola when parameter is String


Library migration: Is it possible to convert a component to a different class when the condition parameter is of type String? Trying something like

convertClassIf("OldClass",
               "stringParameter",
               "blue",
               "NewClass");

fails. This shall trigger conversion of OldClass(stringParameter=\"blue\") into NewClass().

I'm using Dymola 2022x.


Solution

  • It looks like this does not work in Dymola 2022x.

    According to Modelica Specification 3.5 it should be possible:

    The old element should be of a Boolean, Integer, String, or enumeration type and the match is based
    on the literal value of the modifier. For string elements the value argument to convertClassIf shall be
    up-quoted, e.g. "\"My String\"" ...
    

    So this should have worked (And maybe it will in future Dymola versions):

    convertClassIf("OldClass",
                   "stringParameter",
                   "\"blue\"",
                   "NewClass");
    

    But Dymola 2022x just marks classes as modified without changing anything.