/usr/share/titan/help/info/function.html is in eclipse-titan 6.3.1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | <!--
Copyright (c) 2000-2017 Ericsson Telecom AB
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Baji, Laszlo
Balasko, Jeno
Farkas, Laszlo
Szabados, Kristof
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-us">
<title>function</title>
</head>
<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
<tr>
<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>
</tr>
</table>
<table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td>
<td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td>
<td><a href="from.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
<td><a href="get_stringencoding.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td>
</tr>
</table>
<p><br clear="all">
</p>
<hr>
<h1>function</h1>
<blockquote>
<p>1. <a href="#4.">Declaring a function</a></p>
<p>2. <a href="#5."> Declaring an external function</a></p>
</blockquote>
<p>Functions are used to determine test behavior, organize test execution and structure computation. They can be defined within a module or externally; restricted to a component or not. They may
have parameters and return a single value.</p>
<p>Related keywords:</p>
<ul>
<li><a href="in.html"><b><font face="Courier New" color="#003258" size="4">in</font></b></a></li>
<li><a href="inout.html"><b><font face="Courier New" color="#003258" size="4">inout</font></b></a></li>
<li><a href="out.html"><b><font face="Courier New" color="#003258" size="4">out</font></b></a></li>
<li><a href="return.html"><b><font face="Courier New" color="#003258" size="4">return</font></b></a></li>
<li><a href="runs.html"><b><font face="Courier New" color="#003258" size="4">runs</font></b></a> <a href="on.html"><b><font face="Courier New" color="#003258" size="4">on</font></b></a></li>
<li><a href="template.html"><b><font face="Courier New" color="#003258" size="4">template</font></b></a></li>
</ul>
<hr align="left" width="75%">
<h4><a name="4.">1. Declaring a function</a></h4>
<hr align="left" width="50%">
<div align="center">
<center>
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
<tr>
<td width="100%">
<h3 align="center"><font face="Courier New" color="#003258" size="5"><b>function</b></font><i> function_identifier </i> <font face="Courier New" color="#003258" size="5"><b>(</b></font> [<i>
value </i>|<i>timer </i>|<i>template </i>|<i>port </i> ... ] <font face="Courier New" color="#003258" size="5"><b>)</b></font>[ <font face="Courier New" color="#003258" size="5"><b>runs
on</b></font><i> component_reference </i>] [ <font face="Courier New" color="#003258" size="5"><b>return</b></font><i> returned_type </i>] <font face="Courier New" color="#003258" size="5"><b>{</b></font><i>statement_block</i><font
face="Courier New" color="#003258" size="5"><b>};</b></font></h3>
</td>
</tr>
</table>
</center>
</div>
<ul>
<li>
<p>The <font face="Courier New" color="#003258" size="4"><b>function</b></font> keyword introduces the function definition.</p>
</li>
<li>
<p><i>function_identifier</i> is the name used to refer to the function. Must begin with a letter, may contain letters, numbers and underscore characters. According to the <a
href="../docs/naming.pdf" target="_blank">Naming convention</a>, the prefix <b> f_</b> is recommended.</p>
</li>
<li>
<p><a name="inout"><i>value</i> </a> indicates a value parameter. The expression begins with an optional keyword indicating the parameter passing method (<a href="in.html"><font
face="Courier New" size="4"><b>in</b></font></a>, <a href="out.html"><font face="Courier New" size="4"><b>out</b></font></a> or <a href="inout.html"><font face="Courier New" size="4"><b>inout</b></font></a>),
continues with a reference to a built-in type (cf. <a href="const.html#par1">their list</a>) or a <a href="type.html"> referenced type</a> and ends by a parameter
identifier.</p>
</li>
<li>
<p><i>timer</i> indicates a timer parameter. The expression begins with an optional keyword indicating the parameter passing method (<a href="inout.html"><font face="Courier New" size="4"><b>inout</b></font></a>),
continues with the keyword <font face="Courier New"><b>timer</b></font> and ends by a parameter identifier.</p>
</li>
<li>
<p><a name="template"><i>template</i> </a> indicates a template parameter. A template parameter may hold values defined for the value parameter and, in addition, the special value omit,
matching symbols (?, * etc.) and templates. The expression begins with an optional keyword indicating the parameter passing method (<a href="inout.html"><font face="Courier New" size="4"><b>inout</b></font></a>),
continues with the keyword <font face="Courier New"><b>template</b></font>, a reference to a built-in type (cf. <a href="const.html#par1">their list</a>) or a <a href="type.html"
target="_blank"> referenced type</a>and ends by a parameter identifier.</p>
</li>
<li>
<p><i>port</i> indicates a port parameter. The expression begins with an optional keyword indicating the parameter passing method (<a href="inout.html"><font face="Courier New" size="4"><b>inout</b></font></a>),
continues with the port type identifier and ends by a parameter identifier.</p>
</li>
<li>
<p><b>...</b> indicates that all kind of parameters (<i>value</i>, <i>timer</i>, <i>template</i> and <i>port</i>) may be repeated. They are separated by comma.</p>
</li>
<li>
<p><a name="The optional">The optional</a> keywords <font face="Courier New" color="#003258" size="4"><b>runs on</b></font> restrict the function to a component.</p>
</li>
<li>
<p><i>component_reference</i> refers to the component the function is tied to. It is composed of two parts: the module identifier (may be omitted) and the component tpye identifier. The two
parts are linked by a dot.</p>
</li>
<li>
<p><a name="return">The</a> optional keyword <font face="Courier New" color="#003258" size="4"><b>return</b></font> indicates that the function returns a value</p>
</li>
<li>
<p align="left"><i>returned_type</i> is one of the built-in types (cf. <a href="const.html#par1">their list</a>) or <a href="type.html"> referenced types</a>
determining what kind of a value will be returned</p>
</li>
<li>
<p align="left"><i><a name="statement_block">statement_block</a></i> may contain both local definitions (of constants, variables and timers) visible only in the defined function and the program
part describing the program behavior.</p>
</li>
</ul>
<p><a href="#Ex4">Example</a></p>
<hr align="left" width="75%" color="#0094D2">
<h4><a name="5.">2. Declaring an external function</a></h4>
<hr align="left" width="50%" color="#0094D2">
<div align="center">
<center>
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
<tr>
<td width="100%">
<h3 align="center"><font face="Courier New" color="#003258" size="5"><b>external function</b></font><i> function_identifier </i> <font face="Courier New" color="#003258" size="5"><b>(</b></font>
[<i> value </i>|<i>timer </i>|<i>template </i>|<i>port </i> ... ] <font face="Courier New" color="#003258" size="5"><b>)</b></font> [ <font face="Courier New" color="#003258" size="5"><b>return</b></font><i>
returned_type </i>] <font face="Courier New" color="#003258" size="5"><b>;</b></font></h3>
</td>
</tr>
</table>
</center>
</div>
<ul>
<li>
<p>The <font face="Courier New" color="#003258" size="4"><b>external function</b></font> keywords mean that the function is defined in a module other than TTCN-3 or ASN.1 (for example in a
module written in C++).</p>
</li>
<li>
<p><i>function_identifier</i> is the name used to refer to the function. Must begin with a letter, may contain letters, numbers and underscore characters.</p>
</li>
<li>
<p><i>value</i> indicates a value parameter. The expression begins with an optional keyword indicating the parameter passing method (<a href="in.html"><font face="Courier New" size="4"><b>in</b></font></a>,
<a href="out.html"><font face="Courier New" size="4"><b>out</b></font></a> or <a href="inout.html"><font face="Courier New" size="4"><b>inout</b></font></a>), continues with a reference to a
built-in type (cf. <a href="const.html#par1">their list</a>) or a <a href="type.html">referenced type</a> and ends by a parameter identifier.</p>
</li>
<li>
<p><i>timer</i> indicates a timer parameter. The expression begins with an optional keyword indicating the parameter passing method (<a href="inout.html"><font face="Courier New" size="4"><b>inout</b></font></a>),
continues with the keyword <font face="Courier New"><b>timer</b></font> and ends by a parameter identifier.</p>
</li>
<li>
<p><i>template</i> indicates a template parameter. A template parameter may hold values defined for the value parameter and, in addition, the special value omit, matching symbols (?, *
etc.) and templates. The expression begins with an optional keyword indicating the parameter passing method (<a href="inout.html"><font face="Courier New" size="4"><b>inout</b></font></a>),
continues with the keyword <font face="Courier New"><b>template</b></font>, a reference to a built-in type (cf. <a href="const.html#par1">their list</a>) or a <a href="type.html"
target="_blank"> referenced type</a>and ends by a parameter identifier.</p>
</li>
<li>
<p><i>port</i> indicates a port parameter. The expression begins with an optional keyword indicating the parameter passing method (<a href="inout.html"><font face="Courier New" size="4"><b>inout</b></font></a>),
continues with the port type identifier and ends by a parameter identifier.</p>
</li>
<li>
<p><b>...</b> indicates that all kind of parameters (<i>value</i>, <i>timer</i>, <i>template</i> and <i>port</i>) may be repeated. They are separated by comma.</p>
</li>
<li>
<p>The optional keyword <font face="Courier New" color="#003258" size="4"><b>return</b></font> indicates that the function returns a value</p>
</li>
<li>
<p align="left"><i>returned_type</i> is one of the built-in types (cf. <a href="const.html#par1">their list</a>) or <a href="type.html"> referenced types</a>
determining what kind of a value will be returned</p>
</li>
</ul>
<p><a href="#Ex5">Example</a></p>
<hr align="left" width="50%">
<hr align="left" width="50%">
<p><a name="Ex4">Example 1a</a>:
<p><font face="Courier New">function f_MyF_1 (integer pl_1, boolean pl_2) {};</font></p>
<p>The function f_MyF_1 has two input parameters (the integer pl_1 and the Boolean pl_2). No value is returned and the function is not restricted to a given component. The statement block is
empty.</p>
<p>Example 1b:
<p><font face="Courier New">function f_MyF_2() return integer { return 28 };</font></p>
<p>The function f_MyF_2 has no input parameters but an integer value is returned. The function is not restricted to a given component. The statement block is always returns the integer value 28.</p>
<p>Example 1c:
<p><font face="Courier New">function f_MyF_3() runs on MyCompType_CT {};</font></p>
<p>The function f_MyF_3 has neither input parameters nor returns any value. The function is not restricted to the component MyCompType_CT. The statement block is empty.</p>
<p><a name="Ex5">Example 2</a>:
<p><font face="Courier New">external function f_Utifraan() return float;</font></p>
<p>The function called f_Utifraan MonConst is defined in an external module, e.g. in a module written in C++. It has no input parameters but returns a floating point value.</p>
<hr align="left" width="25%">
<hr align="left" width="25%">
<p><a HREF="BNF.html#functiondef">BNF definition</a> of <font face="Courier New"> function</font></p>
</body>
</html>
|