Programmable Filters: Writing custom filters in VBScript / Jscript

 If embedded (predefined) filters are not customizable enough for you, CPS Plus enables you to write more complex filters using VBScript and Jscript scripting language. To use this feature you must have MS Scripting control installed on your computer. Get more details about Microsoft Script Control at http://www.microsoft.com

 

Writing custom filters in VBScript / Jscript

 
 
Image: Programmable filter configuration dialog
 
 Filter can be loaded from file by clicking a “Load Filter From File” button. CPS Plus gives you an extra feature to define if the filter will be executed before or after the embedded (predefined) CPS filters.
 
vbscript filter order of execution
 
CPS Plus requires defined VBS or JS function FilterMain with a single argument.
 
For example:
 
Function FilterMain(p_data)
FilterMain = p_data & " some data "
End Function
 
P_data argumentshould be input data received on COM (Serial) port.
 
Here is a simple example of a function that will append the system time at the end of received data:
 
 
Function FilterMain(p_data)
FilterMain = p_data & Date() & " - " & Time()
End Function
 
 
If function returns empty string, CPS Plus will not log the data.
 
Programmable filters can be also used as an alternative for data logging.
 
You can find more information on this matter in chapter Programmable filters: VBScript Examples