Commit | Line | Data |
---|---|---|
970ed795 | 1 | <!-- |
3abe9331 | 2 | Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
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>break</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="boolean.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> | |
26 | <td><a href="call.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>break</h1> | |
33 | <hr align="left" width="75%"> | |
34 | <p>The keyword is used in loops and <font face="Courier New"><b>alt</b></font>, <font face="Courier New"><b>interleave</b></font> or <font face="Courier New"><b>call</b></font> statements and <font | |
35 | face="Courier New"><b>altstep</b></font> definitions.</p> | |
36 | <p>The <font face="Courier New"><b>break</b></font> statement may only be used inside the body of a loop (<font face="Courier New"><b>for</b></font>, <font face="Courier New"><b>while</b></font>, | |
37 | <font face="Courier New"><b>do-while</b></font>) or an alternative of an <font face="Courier New"><b>alt</b></font> or <font face="Courier New"><b>interleave</b></font> statement or response and | |
38 | exception handling parts of a <font face="Courier New"><b>call</b></font> statement or the statement block of an alternative of an <font face="Courier New"><b>altstep</b></font> definition.</p> | |
39 | <p>When used in loops or <font face="Courier New"><b>alt</b></font>, <font face="Courier New"><b>interleave</b></font> or <font face="Courier New"><b>call</b></font> statements:<br> | |
40 | On executing a <font face="Courier New"><b>break</b></font> statement the innermost, currently executed loop, <font face="Courier New"><b>alt</b></font>, <font face="Courier New"><b>interleave</b></font> | |
41 | or <font face="Courier New"><b>call</b></font> statement is left. Execution continues with the statement following the construct which is left.</p> | |
42 | <p>When used in <font face="Courier New"><b>altstep</b></font> definitions (but not inside a loop or an <font face="Courier New"><b>alt</b></font>, <font face="Courier New"><b>interleave</b></font> | |
43 | or <font face="Courier New"><b>call</b></font> statement):<br> | |
44 | On executing a <font face="Courier New"><b>break</b></font> statement the <font face="Courier New"><b>altstep</b></font> is left. If the <font face="Courier New"><b>altstep</b></font> was explicitly | |
45 | called as an alternative of an <font face="Courier New"><b>alt</b></font> statement or it was called as default for an <font face="Courier New"><b>alt</b></font> statement, then the <font | |
46 | face="Courier New"><b>alt</b></font> statement is also left. If the <font face="Courier New"><b>altstep</b></font> was explicitly called as an alternative with a statement block, then the statement | |
47 | block is skipped (and the <font face="Courier New"><b>alt</b></font> statement is left).</p> | |
48 | <hr align="left" width="50%"> | |
49 | <p>Related keyword:</p> | |
50 | <ul> | |
51 | <li><a href="for.html"><b><font face="Courier New" color="#003258" size="4">for</font></b></a></li> | |
52 | <li><a href="while.html"><b><font face="Courier New" color="#003258" size="4">while</font></b></a></li> | |
53 | <li><a href="do.html"><b><font face="Courier New" color="#003258" size="4">do-while</font></b></a></li> | |
54 | <li><a href="alt.html"><b><font face="Courier New" color="#003258" size="4">alt</font></b></a></li> | |
55 | <li><a href="interleave.html"><b><font face="Courier New" color="#003258" size="4">interleave</font></b></a></li> | |
56 | <li><a href="call.html"><b><font face="Courier New" color="#003258" size="4">call</font></b></a></li> | |
57 | <li><a href="altstep.html"><b><font face="Courier New" color="#003258" size="4">altstep</font></b></a></li> | |
58 | </ul> | |
59 | <hr align="left" width="50%"> | |
60 | <div align="center"> | |
61 | <center> | |
62 | <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> | |
63 | <tr> | |
64 | <td width="100%"> | |
65 | <h3 align="center"><font face="Courier New" color="#003258" size="5"><b>break;</b></font></h3> | |
66 | </td> | |
67 | </tr> | |
68 | </table> | |
69 | </center> | |
70 | </div> | |
71 | <hr align="left" width="25%"> | |
72 | <P>Example 1: | |
73 | <p><code> do {<br> | |
74 | /* ... */<br> | |
75 | if (cond1) { break; /* the do-while loop is left */ }<br> | |
76 | /* ... */<br> | |
77 | for (var integer j:=1; j<=10; j:= j+1) {<br> | |
78 | /* ... */<br> | |
79 | if (cond2) { break; /* the for-loop is left but the do-while loop is continued */ }<br> | |
80 | /* ... */<br> | |
81 | }<br> | |
82 | /* ... */<br> | |
83 | }<br></p> | |
84 | </code> | |
85 | <hr align="left" width="25%"> | |
86 | <P>Example 2: | |
87 | <p><code> interleave {<br> | |
88 | [] PCO1.receive(integer:?) { /* do something here */ }<br> | |
89 | [] PCO2.receive(integer:?) { /* do something here, too */ }<br> | |
90 | [] T.timeout { break; }<br> | |
91 | }<br> | |
92 | </code></p> | |
93 | <p>With the usage of the <font face="Courier New"><b>break</b></font> statement a time limit for the execution of the <font face="Courier New"><b>interleave</b></font> statement is implemented.</p> | |
94 | <hr align="left" width="25%"> | |
95 | <p><a HREF="BNF.html#breakstatement">BNF definition</a> of <font face="Courier New">break</font></p> | |
96 | </body> | |
97 | </html> |