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