User Subroutine Loading Rules
There are three distinctive phases regarding how MotionSolve loads usersub DLLs and functions.
- Resolve the usrsub_dll_name.
- Search and load the DLL.
- Load the subroutine (function) from the DLL.
Phase I: Resolve the DLL Name
The usrsub_dll_name can be explicitly specified as the element attribute in the XML file (element-level specification), as a command line option (model-level specification), or by the environment variable MS_USERSUBDLL (system/machine level specification).
mbd_d input.xml output.mrf usrsub_dll_name
mbd_d input.xml output.mrf
you can check if the environment variable MS_USERSUBDLL is defined or not. If it is, set usrsub_dll_name to what is defined in MS_USERSUBDLL. Otherwise, if MS_USERSUBDLL is not defined, MotionSolve displays an error.
Phase II: Search and Load the DLL
Using the usrsub_dll_name obtained from Phase I, MotionSolve first verifies if the usrsub_dll_name includes an absolute path (for example, usrsub_dll_name = "C:/mydll_dir/myusersub.dll"). In the case of the absolute path, MotionSolve attempts to load the DLL. If it loads successfully, proceed to Phase III. If if fails, MotionSolve displays an error.
- Load it locally, relative to the directory of the XML file, then proceed to Phase III.
- If attempt 1 fails, MotionSolve looks in the NUSOL_DLL_DIR, the standard installation directory (for example <NUSOL_DLL_DIR>/dllname), and proceeds to Phase III.
- If attempt 2 fails, MotionSolve looks in MS_USERDLL_DIR.
Multiple paths can be specified in MS_USERDLL_DIR. For example, c:/mydll_dir1; e:/install/mydll_dir2; c:/mydll_dir3.
They are searched individually until the DLL is found and loaded. Once found, MotionSolve proceeds to Phase III. If all attempts fail and nothing is found, MotionSolve displays an error.
Phase III: Load the Subroutine (function) from the DLL
usrsub_fnc_name = "var101"
usrsub_fnc_name = "NULL"
or the attribute is missing, then the usrsub_fnc_name is assigned a default name depending on the element type. For example, the usrsub_fnc_name for the Reference_Variable element is VARSUB.
After the usrsub_fnc_name is resolved, either by explicit name in the XML file or by default, MotionSolve loads the subroutine (function) from the DLL.