To create a Script Function
-
Select
(Show Functions
) to access the functions.
The Functions dialog opens listing the standard library functions as well as script functions.
- Click (New Script Function) tool in the taskbar. Opens the Script Editor where you can write the script for your function.
- The Script Editor opens with default function name assigned in the header line void Function1(). The tab of Script Editor shows the [New Function].
-
Name the function with proper syntax (other than reserved, key
words) and assign the type.
In our example, replace the type void by double and Function01() by ScriptFunction01.
- Write valid script expressions in the script body and select to register the function.
-
In the Functions dialog list, select the newly created script
function,
ScriptFunction01 and click on the
The
.
functionCall node appears in the graph view.
The auto increment number prefix "1" is added
to a new functionCall node. Existing functionCalls, if available will list
under the
Apply To.. option
Note that the function call functionCall01 drives the script function ScriptFunction01 applied in it.
You can always use the tool icon on the functionCall node to access the Function dialog to amend the function script, and/or assign different function to the function call node.
-
Connect the nodal port to desired input port to supply the return
value of the script function.
In our example, we connect the wire from functionCall01 node to XTransition of point01.
- (Optional) Supply value at input port by clicking the inputVal_1 and run the transaction. The script function doubles the value feed in the inputVal_1 input, and as a result the point1 displaces to that value in the X direction.