PM_CALL_SCRIPT
Syntax
- Input arguments
-
string script_file, script_name Specifies a Plant Modeller specific script file specification for a a binary script file loaded only once during a Plant Modeller session. If left empty, the script is assumed to be in the project-specific Plant Modeller script library.
Return Values
Return value from the called script.
Description
This function can be used to call a script in another file, so a script writer can reuse script code available in other files. However it should be noted that scripts called in this way take considerably longer to execute compared to calling scripts in the same file. It would not be a good idea, for example, to call an external script in a loop. A better approach is to split the code so that calls to external scripts happen "rarely".
If 'script_file' is empty then the script is assumed to be in the project-specific Plant Modeller script library. This is a binary script file that is loaded only once during a Plant Modeller session. Global variables in it maintain their value during the session. There is a separate build script that builds this binary script library from a set of source script files.
If 'script_file' is not empty then it contains a Plant Modeller specific script file specification. This can either select an already compiled script file or a script file in source format. Also the path name can be absolute or relative. Relative pathnames are searched from system (%PMS_HOME%\pm, %PMS_RUNDIR%\pm) directories. If it is an empty string then the script is assumed to be found from the script library.
This call can only check the number of arguments passed to the script. It cannot check their types.
In version 5 there can be script(s) that are saved into COS database. Due this the loading functionality of this API is extended.
Below here is the loading functionality when you call the script by using FILEPATHS:
-
Absolute file path, for example PM_CALL_SCRIPT("C:\temp\script.mac","main")
-
Relative path, for example PM_CALL_SCRIPT(".\script.mac","main"). This would mean that script is run from the directory ...\YourProject.pms\YourWorkspace.wsp\script.mac
Below there is description about the loading functionality in the case that you call the script by using COS DATABASE:
Notice that when loading the script from COS it is enough that you just write the script's name into 'sc_lib' variable.
-
The called script is under COS project under category Pm. The script call would be like this: PM_CALL_SCRIPT("script.mac","main"). However the script object's name in COS database must be just "script".
-
The called script is located under COS library under category Pm. The script call would be like this: PM_CALL_SCRIPT("script.mac","main"). However the script object's name in COS database must be just "script". As you can see the script call is the same than calling the script from project. The only difference is that script from library is run only if there is no script in project with the same name. See section 5 also.
-
There are equally named scripts under COS project database and under system (%PMS_HOME%\pm) => In that case the system will automatically run the script from project database under category Pm.
-
There are equally named scripts under COS library database and under system (%PMS_HOME%\pm) =>In that case the system will automatically run the script from library database under category Pm.
-
There are equally named scripts under COS library database and under COS project database => In that case the system will automatically run the script from project database under category Pm.
-
The script is located under system %PMS_HOME%\pm. This means that script file is not found from Pm category in COS project or library database but user have same named script in %PMS_HOME%\pm.