SCRIPT
Usage
TIBCO iProcess Workspace (Browser)
TIBCO iProcess Workspace (Windows)
This can be used to run a script that is available to the procedure. For more information about scripts, see “Using Scripts” in the TIBCO iProcess Modeler Advanced Design .
This function uses iProcess variables to enable parameters to be input into a script ($ARGnn) and an application defined returned value to be output from a script ($RETURN), when the script is executed. Returning a value from a script is useful if you want to map values to sub-procedure input parameters when a script is executed. See “Defining a Sub-Procedure” in the TIBCO iProcess Modeler Advanced Design for more information about sub-procedures.
Scripts use the following iProcess variables:
• | $ARGn (text) |
The format of the iProcess variable is $ARGn where n is a positive integer. If parameters have been specified for the script, the value of the fields for that parameter are represented as a string. This means that the original values will have to be converted back to their original types within the script. Conversion Functions for information on iProcess functions that can be used to convert data to different formats.
If insufficient arguments have been supplied, the value of the input parameter is SW_NA.
• | $RETURN |
$RETURN is treated as an iProcess field of variable type. It can have a value assigned to it or $RETURN can be used with an expression. When the script has finished executing, the value of this variable is used as the return value of the script. If a value has not been assigned during the execution of the script, the return value is the value of the last expression executed within the script.
Syntax
SCRIPT (scriptname, [param1, ...])
where:
• | scriptname is a text string specifying the name of the script being called. |
• | param is used to define one or more input parameters to the script. These are converted to text type and referenced using $ARGn variable names in the script (where $ARG1 is the first parameter, $ARG2 is the second parameter and so on). |
Returns
One of the following numeric values:
Value |
Description |
0 |
Specified script not found |
-1 |
Error executing or error with syntax when checking the script |
Anything Else |
The resulting data from the $RETURN (vartype) variable. |
Example
For a procedure with the following script called ADDTOBAL that takes 3 arguments (customer name, account balance and an amount to credit the balance by):
; Add credit ($ARG2) to balance ($ARG3)
NEWBAL := NUM($ARG2) + NUM($ARG3)
; Create the return string
; customer name($ARG1) : NEWBAL)
$RETURN := $ARG1 + “: ” + STR(NEWBAL)
; END OF SCRIPT
;
The following expression:
CUSBAL := SCRIPT (“ADDTOBAL”, CUSNAME, BALANCE, CREDIT)
calls the script and when the script has executed, the CUSBAL field has a value in the format CUSTOMER NAME: new balance. For example, John Smith: 325.