Update README.md
[deliverable/titan.core.git] / help / info / sizeof.html
CommitLineData
970ed795
EL
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>sizeof</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 alt="previous" href="signature.html"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
26 <td><a alt="next" href="start.html"><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>sizeof</h1>
33<hr align="left" width="75%">
34<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
35 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
36arrays, the actual value to be returned is the sequential number of the last defined element (index of that element plus 1).
37<hr align="left" width="50%">
38<p>Related keyword:</p>
39<ul>
40 <li><b><font face="Courier New" size="4" color="#003258"><a href="integer.html">integer</a></font></b></li>
41 <li><b><a href="record.html"><font face="Courier New" size="4" color="#003258">record</font></a></b></li>
42 <li><b><a href="set.html"><font face="Courier New" size="4" color="#003258">set</font></a></b></li>
43 <li><b><a href="template.html"><font face="Courier New" size="4" color="#003258">template</font></a></b></li>
44</ul>
45<hr align="left" width="50%">
46<div align="center">
47<center>
48<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
49 <tr>
50 <td width="100%">
51 <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
52 face="Courier New" color="#003258" size="5"><b>) return integer</b></font></h3>
53 </td>
54 </tr>
55</table>
56</center>
57</div>
58<ul>
59 <li>
60 <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>
61 </li>
62</ul>
63<hr align="left" width="25%">
64<p>Example 1:</p>
65<p><font face="Courier New"> &nbsp;&nbsp;type record MyPDU<br>
66&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;boolean field1 optional,<br>
67&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;integer field2<br>
68&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br>
69&nbsp;&nbsp;type record of integer MyPDU1;<br>
70<br>
71&nbsp;&nbsp;const MyPDU MyConst :=<br>
72&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;field1 := true,<br>
73&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field2 := 29<br>
74&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br>
75<br>
76&nbsp;&nbsp;template MyPDU MyTemplate :=<br>
77&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;field1 := omit,<br>
78&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field2 := 5<br>
79&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br>
80<br>
81&nbsp;&nbsp;var integer numElements;<br>
82<br>
83<p>...
84<p>&nbsp;&nbsp;numElements := sizeof(MyConst); // returns 2<br>
85&nbsp;&nbsp;numElements := sizeof(MyTemplate); // returns 1<br>
86</font></p>
87<p>Example 2:</p>
88<p><font face="Courier New"> &nbsp;&nbsp;type record of integer MyRecord;<br>
89&nbsp;&nbsp;var MyRecord MyRecordVar;<br>
90&nbsp;&nbsp;MyRecordVar := { 0, 1, -, 2 };<br>
91<br>
92<p>...
93<p>&nbsp;&nbsp;numElements := sizeof(MyRecordVar);<br>
94&nbsp;&nbsp;// returns 4 without respect to the fact, that the element MyRecordVar[2] is undefined
95</font></p>
96<hr align="left" width="25%">
97</body>
98</html>
This page took 0.026625 seconds and 5 git commands to generate.