Dymola mos script environment variables

烂漫一生 提交于 2021-01-28 09:21:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!