Update README.md
[deliverable/titan.core.git] / help / info / record.html
1 <!--
2 Copyright (c) 2000-2014 Ericsson Telecom AB
3
4 All rights reserved. This program and the accompanying materials
5 are made available under the terms of the Eclipse Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/epl-v10.html
8 -->
9 <html>
10 <head>
11 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
12 <meta http-equiv="Content-Language" content="en-us">
13 <title>record</title>
14 </head>
15 <body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
16 <table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
17 <tr>
18 <td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td>
19 </tr>
20 </table>
21 <table border="0" align="right" cellpadding="0" cellspacing="0">
22 <tr>
23 <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td>
24 <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td>
25 <td><a href="receive.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
26 <td><a href="recursive.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td>
27 </tr>
28 </table>
29 <p><br clear="all">
30 </p>
31 <hr>
32 <h1>record</h1>
33 <hr align="left" width="75%">
34 <p>The keyword denotes a structured type representing an ordered sequence of elements. Each element consists of a type and an identifier.
35 <ul>
36 <li>The record may contain <a href="#Example 1">optional elements</a> which may or may not be present when assigning value to the constructs.</li>
37 <li>Element type can be any basic or user-defined data type.</li>
38 <li>More elements can have same type as long as their identifiers differ.</li>
39 <li>Elements of the record may be accessed using the <a href="#Example 2">dot notation</a>, <a href="#Example 4">value list notation</a> or <a href="#Example 3">assignment notation</a>.</li>
40 <li>The <a href="#Example 5">sizeof()</a> predefined function returns the actual size of the record type parameter, constant, variable or template.</li>
41 <li>The <a href="#Example 6">ispresent()</a> predefined function returns the Boolean value true if the referenced optional field is present in the record.</li>
42 <li>A <a href="#Example 7">record of the same element type</a> may be defined using the keyword <font face="Courier New" color="#003258" size="4"><b>of</b></font>.&nbsp;</li>
43 </ul>
44 <p>Related keywords:</p>
45 <ul>
46 <li><a href="address.html"><font face="Courier New" color="#003258" size="4"><b>address</b></font></a></li>
47 <li><a href="length.html"><font face="Courier New" color="#003258" size="4"><b>length</b></font></a></li>
48 <li><a href="sizeof.html"><font face="Courier New" color="#003258" size="4"><b>sizeof</b></font></a></li>
49 <li><a href="of.html"><font face="Courier New" color="#003258" size="4"><b>of</b></font></a></li>
50 <li><a href="omit.html"><font face="Courier New" color="#003258" size="4"><b>omit</b></font></a></li>
51 <li><a href="optional.html"><font face="Courier New" color="#003258" size="4"><b>optional</b></font></a></li>
52 <li><a href="type.html"><font face="Courier New" color="#003258" size="4"><b>type</b></font></a> &nbsp;</li>
53 </ul>
54 <hr align="left" width="50%">
55 <div align="center">
56 <center>
57 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
58 <tr>
59 <td width="100%">
60 <h3 align="center"><font face="Courier New" color="#003258" size="5"><b>type record</b>&nbsp;</font> (<i>identifier&nbsp;</i> | <font face="Courier New" color="#003258" size="5"><b>address</b></font>)<font
61 face="Courier New" color="#003258" size="5"><b> {</b></font>&nbsp; <i>type_reference</i>&nbsp; <i>element_identifier</i> [ <font face="Courier New" color="#003258" size="5"><b>optional</b></font>
62 ] ... <font face="Courier New" color="#003258" size="5"><b>};</b></font></h3>
63 </td>
64 </tr>
65 </table>
66 </center>
67 </div>
68 <ul>
69 <li>
70 <p>The <a href="type.html"><font face="Courier New" color="#003258" size="4"><b>type</b></font></a> <font face="Courier New" color="#003258" size="4"><b>record</b></font>
71 keywords introduce the type definition.</p>
72 </li>
73 <li>
74 <p><i>identifier</i> is the&nbsp;name used to refer to the record. Must begin with a letter, may contain letters, numbers and underscore characters.</p>
75 </li>
76 <li>
77 <p><a href="address.html"><font face="Courier New" color="#003258" size="4"><b>address</b></font></a> is a user defined type to allow addressing specific entities inside the
78 System Under Test.</p>
79 </li>
80 <li>
81 <p><i>type_reference</i> refers to an already defined (structured or simple) <a href="type.html">type</a>.</p>
82 </li>
83 <li>
84 <p><i>element_identifier</i> identifies the elements of the record. The identifiers must be unique within the same record</p>
85 </li>
86 <li>
87 <p><b>...</b> indicates that&nbsp; <i>type_reference</i> <i>element_identifier</i> pairs may be repeated. They are separated by comma.</p>
88 </li>
89 </ul>
90 <hr align="left" width="75%">
91 <div align="center">
92 <center>
93 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
94 <tr>
95 <td width="100%">
96 <h3 align="center"><font face="Courier New" color="#003258" size="5"> <b>type record</b>&nbsp;</font> [ <font face="Courier New" color="#003258" size="5"><b>length (</b></font><i>record_size</i><font
97 face="Courier New" color="#003258" size="5"><b>)</b></font> ]&nbsp; <font face="Courier New" color="#003258" size="5"><b>of</b>&nbsp;</font> <i>type_reference</i>&nbsp; <i>identifier</i> <font
98 face="Courier New" color="#003258" size="5"><b>};</b></font></h3>
99 </td>
100 </tr>
101 </table>
102 </center>
103 </div>
104 <ul>
105 <li>
106 <p>The <a href="type.html"><font face="Courier New" color="#003258" size="4"><b>type</b></font></a> <font face="Courier New" color="#003258" size="4"><b>record of</b></font>
107 keywords introduce the type definition.</p>
108 </li>
109 <li>
110 <p>The optional <a href="length.html"><font face="Courier New" color="#003258" size="4"><b>length</b></font></a> keyword denotes that the size of the record is restricted.</p>
111 </li>
112 <li>
113 <p><i>record_size</i> is the size restriction. When a single integer value is given, it specifies the exact size of the record. When two integer values are given (separated by two dots), the
114 minimal and the maximal length of the record are given.</p>
115 </li>
116 <li>
117 <p><i>type_reference</i> refers to an already defined (structured or simple) <a href="type.html">type</a>.</p>
118 </li>
119 <li>
120 <p><i>identifier</i> is the&nbsp;name used to refer to the record. Must begin with a letter, may contain letters, numbers and underscore characters.</p>
121 </li>
122 </ul>
123 <hr align="left" width="50%">
124 <p><a name="Example 1">Example 1</a>: type definition
125 <p><font face="Courier New">type record MyRecordType {&nbsp;<br>
126 &nbsp;&nbsp;&nbsp;integer Number1 optional,<br>
127 &nbsp;&nbsp;&nbsp;integer Number2,<br>
128 &nbsp;&nbsp;&nbsp;charstring String<br>
129 }</font>
130 <p>The record called MyRecordType consists of three elements. The first two are both of type integer and have the identifier Number1 and Number2, respectively. Number1 is optional. The third
131 element is of type character string and has the identifier String.</p>
132 <hr align="left" width="50%">
133 <p><a name="Example 2">Example 2</a>: dot notation (For the type definition see example 1)
134 <p><font face="Courier New">var MyRecordType v_myRecord;&nbsp;<br>
135 v_myRecord.Number1 := omit;<br>
136 v_myRecord.Number2 := 12;</font>
137 <p>The variable v_myRecord of type MyRecordType is defined. The first field (Number1) is omitted and the value 12 is assigned to the field Number2.</p>
138 <hr align="left" width="50%">
139 <p><a name="Example 3">Example 3</a>: assignment notation (For the type and variable definition see example 1 &amp; 2)
140 <p><font face="Courier New">v_myRecord := {Number2 := 112};</font>
141 <p>The value 112 is assigned to the field Number2.&nbsp;</p>
142 <hr align="left" width="50%">
143 <p><a name="Example 4">Example 4</a>: value list notation&nbsp; (For the type and variable definition see example 1 &amp; 2)
144 <p><font face="Courier New">v_myRecord</font><font face="Courier New"> := {omit, -, &quot;&quot;};</font>
145 <p>In the value list notation no elements may be absent, dropped optional elements (here: Number1) must explicitly be omitted using the omit keyword. A field value remains unchanged when the
146 'not-used' symbol (–) is applied (here: Number2). The last field will contain an empty string.</p>
147 <hr align="left" width="50%">
148 <p><a name="Example 5">Example 5</a>: the predefined function sizeof()</p>
149 <p><font face="Courier New">v_myRecord := {omit, 191, &quot;s&quot;};<br>
150 var integer v_Stk := sizeof (v_myRecord);</font>
151 <p>The variable v_Stk equals two as there are two elements in v_myRecord (the first one is omitted).</p>
152 <hr align="left" width="50%">
153 <p><a name="Example 6">Example 6</a>: the predefined function ispresent()</p>
154 <p><font face="Courier New">v_myRecord := {omit, 191, &quot;s&quot;};<br>
155 var boolean v_kukuccs := ispresent (v_myRecord.Number1);</font>
156 <p>The variable v_kukuccs equals false as there the referenced element in v_myRecord (Number1) is omitted.</p>
157 <hr align="left" width="50%">
158 <p><a name="Example 7">Example 7</a>: record of the same element type&nbsp;</p>
159 <p><font face="Courier New">type record length (3) of integer IntegerList;<br>
160 var IntegerList v_il := { 71, 92, 83};<br>
161 var integer v_elem := v_il[1];</font>
162 <p>A record of three integers is defined. The record is called IntegerList.&nbsp;<br>
163 To assign values to the elements of the record, value list notation is used. The elements of the record will have the value 71, 92 and 83, respectively.&nbsp;<br>
164 Individual elements of the record may be accessed using the array notation. In the example above the variable v_elem will have the value 92.</p>
165 <hr align="left" width="25%">
166 <hr align="left" width="25%">
167 <p><a HREF="BNF.html#recorddef">BNF definition</a> of <font face="Courier New"> record</font><br>
168 <a HREF="BNF.html#recordofdef">BNF definition</a> of <font face="Courier New"> record of</font></p>
169 </body>
170 </html>
This page took 0.032547 seconds and 5 git commands to generate.