How do I use existing functions (math) from the existing libraries in a new package?

Viewed 50

I'm developing a new package with some simple functions. Now it turns out I could use functions in the already existing "math-vectors" library; specifically "interpolate" and "reverse". How to I use these in my new package? It's clearly not sufficient to write y:=reverse(...) because then I get the error message function reverse not found in scope myTestModel. What syntax applies here?

1 Answers

As suggested in the comments by @Priyanka :

y:=Modelica.Math.Vectors.reverse(...);

or (see also https://mbe.modelica.university/components/packages/importing/ ):

import Modelica.Math.Vectors.reverse; // At the start of your function/model.
...
y:=reverse(...);

For import you can choose from:

import Modelica.Math.Vectors.reverse; // Just this one
import Modelica.Math.Vectors.{reverse,sort}; // More than one.

And additionally there is:

import Modelica.Math.Vectors.*; // All - be careful
import reverse=Modelica.Math.Vectors.sort; // Alias, DON'T!
Related