153 lines
4.6 KiB
HTML
153 lines
4.6 KiB
HTML
|
|
||
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head><META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<title>Leave (LEAVE)</title>
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body bgcolor="white">
|
||
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<a name="LEAVE.Top_Of_Page"></a>
|
||
|
<h2>Leave (LEAVE)</h2>
|
||
|
<table width="100%">
|
||
|
<tr>
|
||
|
<td valign="top" align="left"><b>Where allowed to run: </b>
|
||
|
<ul><li>Batch program (*BPGM)</li>
|
||
|
<li>Interactive program (*IPGM)</li>
|
||
|
</ul><b>Threadsafe: </b>Yes
|
||
|
</td>
|
||
|
<td valign="top" align="right">
|
||
|
<a href="#LEAVE.PARAMETERS.TABLE">Parameters</a><br>
|
||
|
<a href="#LEAVE.COMMAND.EXAMPLES">Examples</a><br>
|
||
|
<a href="#LEAVE.ERROR.MESSAGES">Error messages</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<div> <a name="LEAVE"></a>
|
||
|
<p>The Leave (LEAVE) command ends the processing of commands in the associated DOWHILE, DOUNTIL, or DOFOR loop and passes control to the first command following the associated ENDDO command.
|
||
|
</p>
|
||
|
<p>The following command sequence shows this flow.
|
||
|
</p>
|
||
|
<p>
|
||
|
<pre>
|
||
|
L1: DOWHILE &LGL1
|
||
|
...
|
||
|
L2: DOWHILE &LGL2
|
||
|
...
|
||
|
IF &LGL3 (LEAVE CMDLBL(L1))
|
||
|
IF &LGL4 LEAVE
|
||
|
...
|
||
|
ENDDO
|
||
|
/* Here if &LGL4 evaluates to true */
|
||
|
...
|
||
|
ENDDO
|
||
|
/* Here if &LGL3 evaluates to true */
|
||
|
...
|
||
|
</pre>
|
||
|
</p>
|
||
|
<p><b>Restrictions:</b>
|
||
|
</p>
|
||
|
<ul>
|
||
|
<li>This command is valid only in CL procedures.
|
||
|
</li>
|
||
|
<li>This command is valid only inside a DOWHILE, DOUNTIL, or DOFOR command group.
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#LEAVE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<hr size="2" width="100%">
|
||
|
|
||
|
<div>
|
||
|
<h3><a name="LEAVE.PARAMETERS.TABLE">Parameters</a></h3>
|
||
|
<table border="1" cellpadding="4" cellspacing="0">
|
||
|
<!-- col1="10" col2="15" col3="30" col4="10" -->
|
||
|
<tr>
|
||
|
<th bgcolor="aqua" valign="bottom" align="left">Keyword</th>
|
||
|
<th bgcolor="aqua" valign="bottom" align="left">Description</th>
|
||
|
<th bgcolor="aqua" valign="bottom" align="left">Choices</th>
|
||
|
<th bgcolor="aqua" valign="bottom" align="left">Notes</th>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td valign="top"><a href="#LEAVE.CMDLBL"><b>CMDLBL</b></a></td>
|
||
|
<td valign="top">Command label</td>
|
||
|
<td valign="top"><i>Simple name</i>, <b><u>*CURRENT</u></b></td>
|
||
|
<td valign="top">Optional, Positional 1</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#LEAVE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div> <a name="LEAVE.CMDLBL"></a>
|
||
|
<h3>Command label (CMDLBL)</h3>
|
||
|
<p>The label must be within the same program as the LEAVE command and be a label on an active DOWHILE, DOUNTIL, or DOFOR group. A CL variable name cannot be used to specify the label name.
|
||
|
</p>
|
||
|
<dl>
|
||
|
<dt><b><u>*CURRENT</u></b></dt>
|
||
|
<dd>Leaves the innermost loop surrounding this LEAVE command.
|
||
|
</dd>
|
||
|
<dt><b><i>simple-name</i></b></dt>
|
||
|
<dd>Specify the label name of the surrounding DOWHILE, DOUNTIL, or DOFOR command which is being ended.
|
||
|
</dd>
|
||
|
</dl>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#LEAVE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<hr size="2" width="100%">
|
||
|
<div><h3><a name="LEAVE.COMMAND.EXAMPLES">Examples</a> </h3>
|
||
|
<p><b>Example 1: Leave Simple DOFOR Loop</b>
|
||
|
</p>
|
||
|
<p>
|
||
|
<pre>
|
||
|
DCL VAR(&INT) TYPE(*INT) LEN(2)
|
||
|
DCL VAR(&NAME) TYPE(*CHAR) LEN(10)
|
||
|
:
|
||
|
DOFOR VAR(&INT) FROM(0) TO(10)
|
||
|
: (group of CL commands)
|
||
|
IF COND(&NAME *EQ *NONE) THEN(LEAVE)
|
||
|
: (group of CL commands)
|
||
|
ENDDO
|
||
|
</pre>
|
||
|
</p>
|
||
|
<p>The LEAVE command interrupts processing of the active DOFOR group and processing continues with command following the ENDDO.
|
||
|
</p>
|
||
|
<p><b>Example 2: Leave with Nested Loops</b>
|
||
|
</p>
|
||
|
<p>
|
||
|
<pre>
|
||
|
DCL VAR(&INT) TYPE(*INT) LEN(2)
|
||
|
DCL VAR(&NAME) TYPE(*CHAR) LEN(10)
|
||
|
DCL VAR(&LGL) TYPE(*LGL) VALUE('1') /* True */
|
||
|
:
|
||
|
LOOP1: DOFOR VAR(&INT) FROM(0) TO(10)
|
||
|
: (group of CL commands)
|
||
|
LOOP2: DOUNTIL COND(&LGL)
|
||
|
: (group of CL commands)
|
||
|
IF COND(&NAME *EQ *NONE) THEN(LEAVE CMDLBL(LOOP1))
|
||
|
: (group of CL commands)
|
||
|
ENDDO /* DOUNTIL */
|
||
|
: (group of CL commands)
|
||
|
ENDDO /* DOFOR */
|
||
|
</pre>
|
||
|
</p>
|
||
|
<p>The LEAVE command interrupts processing of both the active DOUNTIL and DOFOR groups and processing continues with command following the ENDDO matching the DOFOR command.
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#LEAVE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<hr size="2" width="100%">
|
||
|
<div><h3><a name="LEAVE.ERROR.MESSAGES">Error messages</a> </h3>
|
||
|
<p>None
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#LEAVE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
</body>
|
||
|
</html>
|