Copyright © Cloud Software Group, Inc. All rights reserved.
Copyright © Cloud Software Group, Inc. All rights reserved.


Chapter 6 Creating Scripts : Using the Script Editor

Using the Script Editor
Using the script editor you can define the statements, conditions and loops that make up the script. You can also edit, save and delete scripts.
This section describes the following topics:
Defining Script Statements
Script statements are entered one per line, and most consist of assignment expressions and calls to functions which perform an action, such as SERVERRUN and WINRUN, which call external programs on the server and the client, respectively. Comments can be included; the rest of the line from a semicolon (;) is ignored. For example:
; The next line runs a program on the Server
serverrun ("/home/myprog", 0)
limit := 10000 ; set maximum estimate
See TIBCO iProcess Expressions and Functions Reference Guide for full details of allowable expressions.
Using Conditions in Scripts
You can include conditions in scripts so that whether or not statements are executed depends upon the values of fields or the results of function calls, etc. This is done as follows:
    IF Condition 1
     True Block
    ELSEIF Condition 2
     Elseif Block
    ELSE
     Else Block
    ENDIF
where:
Condition 1 and Condition 2 are expressions which return type boolean, such as REPLY="Yes".
True Block is a sequence of script statements which are executed if Condition 1 is true.
Elseif Block is a sequence of script statements which are executed if Condition 1 is false and Condition 2 is true.
Else Block is a sequence of script statements which are executed if Condition 1 and Condition 2 are both false.
Note that:
The sequence ELSEIF...Elseif Block is optional and may be repeated a number of times.
The sequence ELSE...Else Block is optional.
Using Loops in Scripts
Using loops in scripts enables sequences of statements to be repeated over and over as long as a condition is satisfied. This is achieved as follows:
    WHILE Condition
     While Block
    WEND
Condition is any expression which returns type boolean, such as REPLY="Yes".
While Block is a sequence of script statements that are executed repeatedly for as long as Condition is true. (The conditional expression is re-evaluated each time.)
Using Parameters in Scripts
A script can contain iProcess variables with the names in the format $ARGn where n is a positive integer. To pass parameter values into a script, the SCRIPT function must be used to execute the script.
See “Script” in TIBCO iProcess Expressions and Functions Reference Guide for more information and an example.
Using Exit Statements
You can exit a script prior to the end by using a statement consisting of the single word EXIT. This would normally be used inside a condition. For example:
    IF REPLY = "YES"
     EXIT
    ENDIF
Combining Constructs
Statements in conditions and loops may consist of other conditions and loops, i.e., structures may be nested freely.
Defining a Field
You can define fields from within the script editor in the same way as in a form. See “Defining Fields” in TIBCO iProcess Modeler Basic Design for further information on how to do this.
Saving Changes
To save the current script file, choose Script > Save Changes.
This does NOT update the Procedure Definition; to do this, choose Procedure > Save from the iProcess Modeler window.
Script Error Checking
On Saving, the script is checked for errors.
Structure errors, for example an IF without a corresponding ENDIF, are reported in a message box. On clicking OK, you are returned to the Script Editor window to correct the error.
You cannot leave the Script Editor window until you have corrected all structure errors.
Expression errors are also reported, but in this case you have the option of returning to correct the error, ignoring it and continuing to check for others, and ignoring them all. If you choose to correct the error, you are shown the line on which the error occurred. Scripts with expression errors will run, but may not produce the desired result.
Exiting the Script Editor
To exit the Script Editor window, choose Script > Exit. If the current script has been changed, you are prompted to Save it first.
Editing a Script
To edit a script, right click on the script in your iProcess Modeler layout and select Script. You are taken to the script which you can then edit and amend as required.
Deleting a Script
To delete a script, select the script on the iProcess Modeler layout and press <Delete>.

Copyright © Cloud Software Group, Inc. All rights reserved.
Copyright © Cloud Software Group, Inc. All rights reserved.