User manual
44
3.6.2 Support for String variables in models
String variables can now be used in models, not only in functions used in models and for
scripting. String variables in model are allocated with a maximum string length. It is defined
by the scripting variable
Advanced.MaxStringLength with default=500. If assignment to
a string variable in a model fails because of the string being too short, truncation is done and
a warning is given in the simulation log window.
String variables cannot be used in models which are exported as FMUs.
3.6.3 Define class from scripting environment
The function Dymola_AST_SetClassText can be used to create a class by scripting.
function Dymola_AST_SetClassText
input String parentName;
input String fullText;
output Boolean ok;
end Dymola_AST_SetClassText;
Giving the following commands creates the usual “Hello world” result:
Dymola_AST_SetClassText("", "function Hello output String s=\"Hello
world\"; algorithm end Hello;");
= true
Hello()
= "Hello world"
The class appears in the package browser and can be used as any other class.
The function will in the next Dymola version also be available as a corresponding function in the
ModelManagement package.
3.6.4 External functions in other languages
Java support extended
The Java interface is now also supported in Linux 32 bit. Note that on Windows only
Windows 32-bit is currently supported.
3.6.5 Minor improvements
• Support of annotation(singleInstance=true) according to Modelica 3.3
specification. This feature is useful for state machines.
• Support of Modelica assert with “level” argument, as described in specification.
• Introduced annotation for functions to force translation (for speed-up) not only of
external functions
annotation(__Dymola_translate=true)