Each script returns an exit value indicating whether the step should be the next step for the SFC number. These return values can be simple true or false values or numeric values to indicate importance.
The simplest case is when the scripts return true or false. This works well when the decisions are mutually exclusive (no two steps can be true at the same time). If several steps return a true value, all of the choices for the next step are displayed to the operator. The operator must then decide among the choices displayed.
To make configuring the scripts easier, it is possible to return a number value (a priority) to help the operator decide which step the routing should proceed to. The number value is displayed on the screen and allows the operator to decide that one path will take priority over other valid (true) paths. A number value allows the example above to return a high priority for the SCRAP (Failure – 3+ Passes) path:
Return |
Next Step |
Script |
---|---|---|
False |
SHIP |
|
True |
PMR (Failure) |
|
600 |
SCRAP (Failure – 3+ Passes) |
|
False |
ASSEMBLE (Missing Component) |
|
Using numeric values simplifies the logic for the PMR ROUTING (Failure) script because the LOOP_COUNT is no longer relevant for this line of code:
if (NC_CODE!=null) exit(true);
The numeric return also keeps the scripts independent of each other. For example, if the customer changes the loop limit to 4 in the SCRAP (Failure – 3+ Passes) script, no changes to the other scripts are necessary.
These return values are treated as priorities to allow some step scripts to return true/false and others to return numbers:
Return |
Priority |
---|---|
True |
500 |
False |
0 |
(Null) |
499 |
(No script) |
499 |
Note
Return steps with the Any Operation or Previous Operation set may have multiple next steps. This means the same script can be executed multiple times, once for each possible return step. The scripts for the next steps are not executed in any specific order.
If an error is found executing a script, the script engine throws an exception. This condition causes the transaction to roll back (including the complete itself). The rollback is also done if there are any other exceptions thrown by the script or any methods it calls. If you do not want the process to fail on script errors, you must catch the exceptions in your script. Note that script syntax errors cannot be caught this way.