![]() |
![]() |
![]() |
![]() |
![]() |
1. Declaring a variable of built-in type
2. Declaring a variable of referenced type
var ( bitstring | boolean | charstring | universal charstring | integer | octetstring | objid | hexstring | verdicttype | float | address | default | anytype ) var_identifier [:= single_variable_expression ] ; |
The var keyword introduces the variable definition.
bitstring denotes an a type whose distinguished values are the ordered sequences of zero, one, or more bits.
boolean is a simple basic type consisting of two distinguished values (namely true or false).
charstring denotes a type whose distinguished values are the ordered sequences of characters of ISO/IEC 646 as described in ITU-T Recommendation T.50.
universal charstring denotes a type whose distinguished values are the ordered sequences of UCS-4 coded representation of ISO/IEC 10646 characters.
integer denotes a a type with distinguished values which are the positive and negative whole numbers, including zero.
octetstring stands for a a type whose distinguished values are the ordered sequences of zero or a positive even number of hexadecimal digits (every pair of digits corresponding to an ordered sequence of eight bits).
objid defines a type whose distinguished values are the set of all object identifiers conforming to clause 6.2 of ITU-T Recommendation X.660.
hexstring defines a type whose distinguished values are the ordered sequences of zero, one, or more hexadecimal digits, each corresponding to an ordered sequence of four bits.
verdicttype defines a type for use with test verdicts consisting of 5 distinguished values.
float defines a type to describe floating-point numbers.
address denotes a user defined type to allow addressing specific entities inside the system under test.
default is a reference to an activated default resulting from an activate operation.
TITAN specific restriction compared to the standard: anytype is not implemented yet.
|
var_identifier is the name used to refer to the variable. Must begin with a letter, may contain letters, numbers and underscore characters.
According to the Naming convention, the following prefixes are recommended:
vld_ for variables defined in testcases or functions used to store references to activated defaults (returned by an activate statement),
The optional single_variable_expression is used to define an initial value. It may contain variables and literal values as operands. The result of the expression must correspond to the type of the variable.
var [ module_id [.obj_id ].] type_reference [.field_reference ] var_identifier
[:=
|
The var keyword introduces the variable definition.
module_id is needed when the referenced type is defined in another TTCN-3 module and denotes the name of that module.
TITAN specific restriction compared to the standard: objid is not implemented yet; it is discarded when encountered.
|
type_reference refers to an already defined (structured or simple) type.
TITAN specific restriction compared to the standard: field reference can only be used with structured variables defined in the module definition part.
|
var_identifier is the name used to refer to the variable. Must begin with a letter, may contain letters, numbers and underscore characters.
The optional single_variable_expression may contain variables and literal values as operands. The result of the expression must correspond to the type of the variable. Used with simple types to define an initial value.
The optional value_list is a comma-separated list of the variable values between curly brackets. Used with structured types to define an initial value
TITAN specific restriction compared to the standard: value assignment can only be used with structured variables defined in the module definition part.
|
var type identifier1 [ := variable_expression1], identifier2 [:= variable_expression2 ]⦠; |
The var keyword introduces the variable definition.
type is one of the built-in types mentioned in paragraph 1 or referenced types mentioned in paragraph 2 .
identifiern is the name used to refer to the nth variable.
The optional variable_expressionn determines the initial value of the nth variable.
var type var_identifier [ array_index ] [:= value_list]; |
The var keyword introduces the variable definition.
type is one of the built-in types mentioned in paragraph 1 or referenced types mentioned in paragraph 2 .
var_identifier is the name used to refer to the variable. Must begin with a letter, may contain letters, numbers and underscore characters.
array index is a non-negative integer value corresponding to the number of elements in the array.
Alternatively, the lower and upper index values are given joined by two dots.
The optional value_list is a comma-separated list of the initial variable values between curly brackets.
var integer v_myVariable := 127;
A variable called v_MyVariable is defined. The variable will have the initial value one hundred twenty seven.
Example 1b:
var bitstring v_myGarland := '00101101'B;
var bitstring v_myBiggerGarland := v_myGarland & '11000010'B;
Two variables are defined. The one called v_myBiggerGarland initially will have the binary value 11101111.
type record E_Rec {integer field1, boolean field2}; //defined in Elsewhere
var Elsewhere.E_Rec v_CurrVar := {17, true};
A record called E_Rec have been defined in the TTCN-3 module Elsewhere. In the current module we define a variable named v_CurrVar and assign values to all of its fields. In TITAN, the value notation as shown above may only be used in the module definition part.
Example 2b:
type record G_Rec {float first_field, hexstring last_field};
var G_Rec.last_field v_FuzerVar;
First we define a record called G_Rec. Then we define a variable named v_FuzerVar derived from the second field of the referred type and assign no initial value to it.
Example 2c:
type record G_Rec {float first_field, hexstring last_field};
var G_Rec v_UeppigVar := {
first_field := 5.77,
last_field := '55'H;
}
First we define a record called G_Rec. Then we define a variable named v_UeppigVar and assign initial values to both of its fields using assignment notation.
var boolean v_MyVar2 := true, v_MyVar3;
Two variables (v_MyVar2 and v_MyVar3) are declared within one operation. The latter variable has no initial value assigned.
var boolean v_MinVar[3] := { true, false, false };
The array defined v_MinVar consists of three elements indexed from 0 to 2.
Example 4b:
var boolean v_DinVar[7..9] := { true, false, false };
The array defined v_DinVar consists also of three elements as in the example 4a, but here the indices run from 7 to 9.
BNF definition of var