| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
on |
| 16 |
|
| 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>sizeof</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 alt="previous" href="signature.html"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> |
| 34 |
<td><a alt="next" href="start.html"><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>sizeof</h1> |
| 41 |
<hr align="left" width="75%"> |
| 42 |
<p>This function returns the declared number of elements of a <b><font face="Courier New">record, record of, set, set of</font></b> type or the actual number of elements of a constant, variable, <b><font |
| 43 |
face="Courier New">template</font></b> of these types or array. In the case of <b><font face="Courier New">record of</font></b> and <b><font face="Courier New">set of</font></b> values or templates or |
| 44 |
arrays, the actual value to be returned is the sequential number of the last defined element (index of that element plus 1). |
| 45 |
<hr align="left" width="50%"> |
| 46 |
<p>Related keyword:</p> |
| 47 |
<ul> |
| 48 |
<li><b><font face="Courier New" size="4" color="#003258"><a href="integer.html">integer</a></font></b></li> |
| 49 |
<li><b><a href="record.html"><font face="Courier New" size="4" color="#003258">record</font></a></b></li> |
| 50 |
<li><b><a href="set.html"><font face="Courier New" size="4" color="#003258">set</font></a></b></li> |
| 51 |
<li><b><a href="template.html"><font face="Courier New" size="4" color="#003258">template</font></a></b></li> |
| 52 |
</ul> |
| 53 |
<hr align="left" width="50%"> |
| 54 |
<div align="center"> |
| 55 |
<center> |
| 56 |
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> |
| 57 |
<tr> |
| 58 |
<td width="100%"> |
| 59 |
<h3 align="center"><font face="Courier New" color="#003258" size="5"><b>sizeof</b></font><font face="Courier New" color="#003258" size="5"><b>(</b></font><i>structured_type value</i><font |
| 60 |
face="Courier New" color="#003258" size="5"><b>) return integer</b></font></h3> |
| 61 |
</td> |
| 62 |
</tr> |
| 63 |
</table> |
| 64 |
</center> |
| 65 |
</div> |
| 66 |
<ul> |
| 67 |
<li> |
| 68 |
<p>Only elements of the TTCN-3 object, which is the parameter of the function are calculated; i.e. no elements of nested types/values are taken into account at determining the return value.</p> |
| 69 |
</li> |
| 70 |
</ul> |
| 71 |
<hr align="left" width="25%"> |
| 72 |
<p>Example 1:</p> |
| 73 |
<p><font face="Courier New"> type record MyPDU<br> |
| 74 |
{ boolean field1 optional,<br> |
| 75 |
integer field2<br> |
| 76 |
};<br> |
| 77 |
type record of integer MyPDU1;<br> |
| 78 |
<br> |
| 79 |
const MyPDU MyConst :=<br> |
| 80 |
{ field1 := true,<br> |
| 81 |
field2 := 29<br> |
| 82 |
};<br> |
| 83 |
<br> |
| 84 |
template MyPDU MyTemplate :=<br> |
| 85 |
{ field1 := omit,<br> |
| 86 |
field2 := 5<br> |
| 87 |
};<br> |
| 88 |
<br> |
| 89 |
var integer numElements;<br> |
| 90 |
<br> |
| 91 |
<p>... |
| 92 |
<p> numElements := sizeof(MyConst); // returns 2<br> |
| 93 |
numElements := sizeof(MyTemplate); // returns 1<br> |
| 94 |
</font></p> |
| 95 |
<p>Example 2:</p> |
| 96 |
<p><font face="Courier New"> type record of integer MyRecord;<br> |
| 97 |
var MyRecord MyRecordVar;<br> |
| 98 |
MyRecordVar := { 0, 1, -, 2 };<br> |
| 99 |
<br> |
| 100 |
<p>... |
| 101 |
<p> numElements := sizeof(MyRecordVar);<br> |
| 102 |
// returns 4 without respect to the fact, that the element MyRecordVar[2] is undefined |
| 103 |
</font></p> |
| 104 |
<hr align="left" width="25%"> |
| 105 |
</body> |
| 106 |
</html> |