Variables store global and local data for instances. Instances save, hold, modify and share data using variables. A Flowchart comes with a number of predefined environment variables and mechanisms for defining new variables.
Variables values could be changed during Flowchart execution to support any finite-state machine logic required; a field of an outgoing packet can be filled by a current value of a variable; any part or a whole of a packet received could be stored into a variable by a Receive Block. The packet data is saved in the decoded form with easy access to all the saved PDU fields by name.
Variables can be defined by a Flowchart and/or imported. Include files with variables definitions are supported.
Variables List dialog can be opened:
- By clicking Variables button on Tool bar
- By Edit >> Variables List… command
- By clicking Variables List icon in other dialogs
Variables List dialog fields:
- Line number
- Variable name
- Variable data type
- Variable initial value
- Variable scope
- Variable source
- Control buttons
- Text includes list
All variables are visible via Variables List, but only variables defined via this dialog could be deleted through it. Variables defined via include mechanisms have to be deleted at the source.
Deleting a variable has dangerous side effects. It erases all operations and conditions associated with the variable throughout the Flowchart. Changing variables type may have the same effect. This behavior is by design. Making a backup copy of the Flowchart before attempting to delete a variable is strongly advised.
- Name – Variable name
- Type – Variable type.
- Default Value – Default value
- Scope – The scope of the variable
- Description – Text description
A variable name should start with a latter and may contain any number of alphanumeric characters and underscores. Names of API calls and some keywords are prohibited.
Data type of a variable defines what kind of a value the variable can hold.
|boolean||Logical value. Can be ‘True’ or ‘False’.|
|bitStr||Bit string type. Example: “10010100100011101010”|
|octetStr||Octet string type. Example: “DE AD BE EF”. A pair of hex digits represents an octet (byte). Octets are space-separated.|
|charStr||Common char string. Example: “Hello world”|
|objId||ASN.1 object identifier type (section 31 of ITU-T Recommendation X.680)|
|any||This is a UNION of other types supported. For example, during initialization one can address this variable as: VariableName.integer - to assign it an integer value; VariableName.boolean - to assign it a Boolean value. After the initialization, the variable acquires its final type, and keeps it for the rest of the test.|
Variables of any structured data type present at a supported protocol specs can be defined. That allows FlowCoder to work with any structured data present in the network straffic.
FlowCoder allows saving, analyzing and modifying any fragment of any packet at any level of detail on-the-fly at any point of Flowchart execution.
A variable is statically assigned one of the scopes:
- Instance scope – A variable existing in a specific instance context. Each instance has a separate value of it.
- Global scope – A variable shared by all instances. Any instance could access and modify gobally scoped variable’s value.
- Const scope – A read-only variable, has the same non-modifiable value for all instances.
A global variable may serve as a basic synchronization mechanism among instances.
The software guarantees atomicity of access to global variables and API calls. No special actions on user the part are required.
Any value of the same data type as the variable.
x := charStr;
charStr[i] := "F";
x := octS;
octS[i] := 5;
bitS := 0;
bitS := 1;
charCount := Len(charStr);
octetCount := Len(octS);
bitCount := Len(bitS);
octS := "A5 CA D4";
octS := octS + "EF 56"; // add 2 literal octets
octS := octS + Str(Octet) + Str(yetOneMore); // add 2 octets from integer vars
octS := octS1 + octS2; // concatenate 2 octet strings
<> comparisons supported for all strings, and work similarly to charStr type.