Sync with 5.4.0
[deliverable/titan.core.git] / help / info / while.html
1 <!--
2 Copyright (c) 2000-2015 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>while</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="verdicttype.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
26 <td><a href="with.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>while</h1>
33 <hr align="left" width="75%">
34 <p>The keyword is used...
35 <ol>
36 <li><a href="#keyword">alone</a> to define a loop where the loop condition is checked before of each new loop iteration (see below);</li>
37 <li>together with the keyword <a href="do.html"><b><font face="Courier New" color="#003258" size="4">do</font></b></a> to define a loop where the loop condition is checked before of each new
38 loop iteration.</li>
39 </ol>
40 <hr align="left" width="50%">
41 <p>The <a name="keyword"> keyword</a> defines on its own a loop which is executed as long as the loop condition holds. The loop condition shall be checked at the beginning of each new loop
42 iteration. If the loop condition does not hold, then the loop is exited and execution shall continue with the statement, which immediately follows the loop.</p>
43 <hr align="left" width="50%">
44 <div align="center">
45 <center>
46 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
47 <tr>
48 <td width="100%">
49 <h3 align="center"><font face="Courier New" color="#003258" size="5"><b>while (</b></font><i> condition</i><font face="Courier New" color="#003258" size="5"><b>) {</b></font>&nbsp;<i>
50 statement_block </i><font face="Courier New" color="#003258" size="5"><b>};</b></font></h3>
51 </td>
52 </tr>
53 </table>
54 </center>
55 </div>
56 <ul>
57 <li>
58 <p>The <font face="Courier New" color="#003258" size="4"><b>while</b></font> keyword introduces the loop.</p>
59 </li>
60 <li>
61 <p><i>condition</i> is a Boolean expression. It is checked at the beginning of each new loop iteration. If it evaluates to false, the loop terminates.</p>
62 </li>
63 <li>
64 <p><i>statement_block</i> contains one or more statements. The block will be executed in a loop provided <i>condition</i> is true.</p>
65 </li>
66 </ul>
67 <hr align="left" width="50%">
68 <p>Example 1:
69 <p><font face="Courier New">var integer i := 3;&nbsp;<br>
70 while (i&lt;=10) {i:= i+2 }<br>
71 </font>
72 <p>The loop variable i is declared in the first line and it is given the initial value 3. In the second line, a loop is defined.&nbsp; The loop execution terminates when the index value will have
73 a value greater than 10. In the statement block the index variable is increased by 2 every time the loop is executed. The loop will be executed 5 times.</p>
74 <hr align="left" width="25%">
75 <hr align="left" width="25%">
76 <p><a HREF="BNF.html#whilestatement">BNF definition</a> of <font face="Courier New">while</font></p>
77 </body>
78 </html>
This page took 0.047101 seconds and 6 git commands to generate.