PI_CALL_SCRIPT

Syntax

untyped_val = PI_CALL_SCRIPT ( script_file, script_name [,arg1, arg2 ...] );
Input arguments
string script_file The path to the script file.
string script_name The name of the script function to call.
variable arg1, arg2 … The argument list for the script function to call.

Return Values

Success:
The return value from the called script.

Description

This function can be used to call a script in another file. See also DM_CALL_SCRIPT and DW_CALL_SCRIPT. The first argument is the path name to a script file. If it is an empty string then the script is assumed to be found from the script library. The path can be relative or absolute. Relative pathnames are searched from system (%PMS_HOME%\pi, %PMS_RUNDIR%\pi) directories. If the file name ends with ".bs" then the file is assumed to be a loadable compiled script file.

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:

  1. Absolute file path, for example PI_CALL_SCRIPT("C:/temp/script.mac","main"

  2. Relative path, for example PI_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.

  1. The called script is under COS project under category Pi. The script call would be like this: PI_CALL_SCRIPT("script.mac","main"). However the script object's name in COS database must be just "script".

  2. The called script is located under COS library under category Pi. The script call would be like this: PI_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.

  3. There are equally named scripts under COS project database and under system (%PMS_HOME%\pi) => In that case the system will automatically run the script from project database under category Pi.

  4. There are equally named scripts under COS library database and under system (%PMS_HOME%\pi) =>In that case the system will automatically run the script from library database under category Pi.

  5. 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 Pi.

  6. The script is located under system %PMS_HOME%\pi. This means that script file is not found from Pi category COS project or library database but user have equally named script in %PMS_HOME%\pi.