问题
Is there a way to use the Windows environment variables in Dymolas .mos
scripts?
Something like this:
// Load libraries, last one determines the working directory
openModel(%USERPROFILE% + "Documents/Dymola/MyTestLib/package.mo");
Alternatively, does Dymola know some other predefined pathes? I would like to make .mos script a bit more portable to a different PC.
回答1:
You can use the getEnvironmentVariable
function from the MSL.
So this should do what you want:
user_profile = Modelica.Utilities.System.getEnvironmentVariable("USERPROFILE", convertToSlash=true);
openModel(user_profile + "/Documents/Dymola/MyTestLib/package.mo");
On startup Dymola also defines two useful environment variables:
- DYMOLA: the dymola installation directory, e.g.
C:/Program Files/Dymola 2019 FD01
- DYMOLAWORK: the startup directory, with
C:/Users/<user>/Documents/Dymola
as default. See user Manual 1 for details.
来源:https://stackoverflow.com/questions/53468841/dymola-mos-script-environment-variables