To build a custom criterion 4 steps need to taken:
- Planning the criterion. Make sure you know what to test and how
- Creating the VB-script.It’s best to prepare and test the script code before using it.
- Building the Criterion.Create the conditions and parameters.
- Testing the Criterion.Test the Criterion with a real Scense TaskSet.
In this example a Criterion is created that accepts 3 numeric parameters.
The Criterion will test how the sum of the first two parameters compare to the third parameter.
This is easily done with a VB-script.
Once steps 1 and 2 are taken and there’s a working script algorithm the next step can be taken: Building the Criterion.
First the Criterion header should be specified:
After thisthe first condition should be created including the vb-script code.
In most cases this will be the condition that checks for ‘equal’.
- This first condition will be the default condition when this Criterion is used in the Scense Explorer. To make working with this Criterion comfortable you should plan to make the first Condition the one that is most often used. You can change the default Condition afterwards by exporting the Criterion and manually editing the SCX-file, and then importing it back in.
The ‘Function Type’ should be set to ‘VB-Script’, the ‘Operator Type’ to ‘= (Equal)’ and the ‘Function Name’ should be specified, in this case it’s ‘Sum’.
‘Sum’ is the actual name of the function that should be available in the VB-Script.
Clicking the ‘Edit Script’ button will pop up the script editor in which the script can be written or pasted.
The above function accepts the three parameters, adds par1 and par2 and does several comparisons to determine the right condition operator to be returned.
Then the rest of the Conditions can be created and linked to the same Function Name (however, it is possible to use different scripts to test the conditions in different ways).
After creating all Conditions the Parameters can be created.
Make sure the ‘Argument Name’ matches the parameter names as they are accepted by the VB-script function. The ‘Data Type’ is set to ‘string’ and the Regex in the ‘Data Range’ forces the user to enter numeric data only.
After clicking OK the new Criterion is saved and ready for testing.
The Criterion will appear in the Criteria selector like this:
After selecting the Criterion it can be configured in the Scope- or Condition property page:
The parameters can be configured and will accept only numeric values.
All conditions are available in the dropdown list: