This section describes the way how the record fields should be worked with. As you know, each component may have ports. Both input and output ports are numbered starting from 0.
Metadata of connected edges may be identified by names or IDs.
Metadata consist of fields.
Now we suppose that ID of metadata of an edge connected to the
first port (port 0) - independently of whether it is input or output -
is Customers
, their name is
customers
, and their third field (field 2) is
firstname
.
Following expressions represent the value of the third field (field 2) of the specified metadata:
$<port number>.<field number>
Example: $0.2
$0.*
means all fields on the first port
(port 0).
$<port number>.<field name>
Example: $0.firstname
$<metadata name>.<field number>
Example: $customers.2
$customers.*
means all fields on the
first port (port 0).
$<metadata name>.<field name>
Example: $customers.firstname
For input data following syntax can also be used:
@<port number>[<field number>]
Example: @0[2]
@0
means the whole input record incoming
through the first port (port 0).
@<metadata name>[<field number>]
Example: @customers[2]
@customers
means the whole input record
whose metadata name is customers
.
Integer variables can also be used for identifying field numbers
of input records. When an integer variable is declared (int index;
),
following is possible:
@<port number>[index]
Example: @0[index]
@<metadata name>[index]
Example: @customers[index]
Remember that metadata name may be the same for multiple edges.
This way you can also create loops. For example, to print out field values on the first input port you can type:
int i; for (i=0; i<length(@0); i++){ print_err(@0[i]); }
You can also define records in CTL code. Such defitions can look like these:
record (metadataID) MyCTLRecord;
Example: record (Customers)
MyCustomers;
record (@<port number>) MyCTLRecord;
Example: record (@0) MyCustomers;
This is possible for input ports only.
record (@<metadata name>)
MyCTLRecord;
Example: record (@customers)
MyCustomers;
Records from an input edge can be assigned to records declared in CTL in the following way:
MyCTLRecord = @<port number>;
Example: MyCTLRecord = @0;
Mapping of records to variables looks like this:
myVariable =
$<port number>.<field number>;
Example: FirstName = $0.2;
myVariable =
$<port number>.<field name>;
Example: FirstName = $0.firstname;
myVariable =
$<metadata name>.<field number>;
Example: FirstName = $customers.2;
Remember that metadata names should be unique. Otherwise, use port number instead.
myVariable =
$<metadata name>.<field name>;
Example: FirstName =
$customers.firstname;
Remember that metadata names should be unique. Otherwise, use port number instead.
myVariable =
@<port number>[<field number>];
Example: FirstName = @0[2];
myVariable =
@<metadata name>[<field number>];
Example: FirstName =
@customers[2];
Remember that metadata names should be unique. Otherwise, use port number instead.
Mapping of variables to records can look like this:
$<port number>.<field number> :=
myVariable;
Example: $0.2 := FirstName;
$<port number>.<field name> :=
myVariable;
Example: $0.firstname :=
FirstName;
$<metadata name>.<field number> :=
myVariable;
Example: $customers.2 :=
FirstName;
$<metadata name>.<field name> :=
myVariable;
Example: $customers.firstname :=
FirstName;