本文介绍了Dymola mos脚本环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在Dymolas .mos
脚本中使用Windows环境变量?
像这样:
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");
或者,Dymola是否知道其他一些预定义的路径?我想使.mos脚本更易于移植到另一台PC.
Alternatively, does Dymola know some other predefined pathes?I would like to make .mos script a bit more portable to a different PC.
推荐答案
您可以从MSL使用 getEnvironmentVariable
函数.
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");
在启动时,Dymola还定义了两个有用的环境变量:
On startup Dymola also defines two useful environment variables:
- DYMOLA:dymola安装目录,例如
C:/Program Files/Dymola 2019 FD01
- DYMOLAWORK:启动目录,默认目录为
C:/Users/< user>/Documents/Dymola
.有关详细信息,请参见用户手册1.
- 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.
这篇关于Dymola mos脚本环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!