DM_CALL_SCRIPT
Syntax
- Input arguments
-
- Optional input/output arguments
-
variable arg1, arg2, … The argument list for the script function to be called.
Return Values
Standard
Description
This function can be used to call a script function located in another file or in the same file, allowing the reuse of existing code. Although the call can be made in Plant Modeller, P&ID, or Piping Isometrics & Spools, the script being called must contain only Datamatic script functions that run under DM_TOOLS.
When needing to call a script that contains application-specific script functions, use the following instead:
|
Plant Modeller |
|
|
P&ID |
|
|
Piping Isometrics & Spools |
Calls using a file path
The script file can be loaded from the file system by using an absolute or relative file path.
| Call | Details |
|---|---|
|
DM_CALL_SCRIPT("C:\temp\script.mac", "hello_world") |
This call uses an absolute path to load the script from C:\temp\script.mac. |
|
DM_CALL_SCRIPT(".\script.mac", "hello_world") |
This call uses the relative path .\ which under DM_TOOLS loads the script from the workspace folder: <project>.pms\<workspace>.wsp\script.mac. |
|
DM_CALL_SCRIPT("..\script.mac", "hello_world") |
Under DM_TOOLS, using the relative path ..\ is not recommended because it loads the script from the parent folder of the workspace folder, and this can be either the real project folder or the local parent of the workspace folder. Under design applications (.pm, .pd, .pi), this relative path loads the script from the workspace folder: <project>.pms\<workspace>.wsp\script.mac. |
Calls using the COS database
The script file can be loaded from the 'common' category of either the library or project database by omitting the path:
DM_CALL_SCRIPT("script.mac", "hello_world")
Note: The call specifies whether the target script is a precompiled file (.bs) or a script source file (.mac). However, in the COS database, the file name is always just "script" without the extension.
The function call searches for the file name and runs it from the first applicable location in this order:
-
The script is found in the project database. In this case, all other locations are ignored and the script is run from the project database.
-
The script is found in the library database, but not in the project database. In this case, all other locations are ignored and the script is run from the library database.
-
The script is found under the system directory %PMS_HOME%\dm, but not in the project or library database. In this case, the script is run from the system directory.