Custom Script Block
The Script Block is used to write customized code that can interact with incoming and outgoing packets. The C/C++ like syntax can be easily learned, even by non-programmers, based on the many examples and documentation that is available. If a special function is needed and none of the other blocks can do it, the scripting will be able to fill the gap. Easily implement advanced filters, triggered responses, data encryption/decryption, end-of-line testing procedures, node emulators, etc.
The scripting block is designed to handle any miscellaneous yet advanced features that may be needed, while being simple enough to pick-up and learn quickly. To help make things easier, the code window has an auto-complete function that provides popup call-tips and function definitions to help present all available options. For example, incoming and outgoing messages are represented by an object called Message; by typing the Message variable name followed by a `.`, all available functions to manipulate the message data will be shown. The available functions are all very easy to understand; for example, message.GetDataLength() will return the data length of the respective packet and block.SendMessage(1, message) will send the current message out the first output port of the block.
Each script block has a code window as well as an output window associated with it. The code window is used to enter the script that will be executed, and the output window can be used to display messages for diagnostic purposes. To print text to the script's output window, simply call the functionblock.PrintOutputText(TextHere) from anywhere in code.
All custom code is executed as a response to a few key application events. For example, the following three functions are executed when a capture is started, a message is received, and a capture is stopped:
void OnStartCapture(ScriptBlock thisBlock);
void OnReceiveMessage(uint8 inPort, ScriptBlock thisBlock, Message &msg);
void OnStopCapture(ScriptBlock thisBlock);
When a new script block is created, it will automatically contain example code that has these three functions already completed. The example code simply prints information about every received message with ID 61444 to the output window. It also forwards every incoming message out the corresponding output port.