There are three distinctive phases regarding how MotionSolve loads usersub DLLs and functions. They include:
1. | Resolve the usrsub_dll_name. |
2. | Search and load the DLL. |
3. | Load the subroutine (function) from the DLL. |
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 If usrsub_dll_name is explicitly specified in the XML, (for example, usrsub_dll_name = "msautoutils" or usrsub_dll_name = "msautoutils.dll"), proceed to Phase II. Otherwise, if usrsub_dll_name is not defined in the XML (for example: usrsub_dll_name = "NULL"), check if the MotionSolve executable was invoked with an optional usrsub_dll_name. For example, mbd_d input.xml output.mrf usrsub_dll_name If the optional usrsub_dll_name is present in the command line, proceed to Phase II. Otherwise, if the optional usrsub_dll_name is absent in the command line as in, 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. |
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 = If the DLL name is not an absolute path, then MotionSolve tries to do the following in sequence:
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. |
After the userdll is loaded in Phase II, MotionSolve checks if the usrsub_fnc_name is specified in the XML file. For example, usrsub_fnc_name = "var101" If the usrsub_fnc_name is not specified in the XML file, for example: 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. |