ibm-information-center/dist/eclipse/plugins/i5OS.ic.cl_5.4.0.1/dowhile.htm

124 lines
4.4 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Do While (DOWHILE)</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="DOWHILE.Top_Of_Page"></a>
<h2>Do While (DOWHILE)</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="#DOWHILE.PARAMETERS.TABLE">Parameters</a><br>
<a href="#DOWHILE.COMMAND.EXAMPLES">Examples</a><br>
<a href="#DOWHILE.ERROR.MESSAGES">Error messages</a></td>
</tr>
</table>
<div> <a name="DOWHILE"></a>
<p>The Do While (DOWHILE) command evaluates a logical expression and conditionally processes CL procedure commands according to the evaluation of the expression. If the logical expression is true (a logical 1), the commands in this Do While group are processed as long as the expression continues to evaluate to TRUE. If the logical expression evaluates to false (a logical 0), control passes to the next command following the associated ENDDO command.
</p>
<p><b>Restrictions:</b>
</p>
<ul>
<li>This command is valid only within a CL procedure.
</li>
<li>Up to 25 levels of nested DO, DOWHILE, DOUNTIL, and DOFOR commands are allowed.
</li>
</ul>
</div>
<table width="100%">
<tr><td align="right"><a href="#DOWHILE.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div>
<h3><a name="DOWHILE.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="#DOWHILE.COND"><b>COND</b></a></td>
<td valign="top">Condition</td>
<td valign="top"><i>Logical value</i></td>
<td valign="top">Required, Positional 1</td>
</tr>
</table>
<table width="100%">
<tr><td align="right"><a href="#DOWHILE.Top_Of_Page">Top</a></td></tr>
</table>
</div>
<div> <a name="DOWHILE.COND"></a>
<h3>Condition (COND)</h3>
<p>Specifies the logical expression that is evaluated to determine a condition in the program and whether the loop is processed again. Refer to "Logical Expressions" in the CL concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter for a description of logical expressions. Note that variables, constants, and the %SUBSTRING, %SWITCH, and %BINARY built-in functions can be used within the expression.
</p>
<p>This is a required parameter.
</p>
<dl>
<dt><b><i>logical-value</i></b></dt>
<dd>Specify the name of a CL logical variable or a logical expression.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#DOWHILE.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div><h3><a name="DOWHILE.COMMAND.EXAMPLES">Examples</a> </h3>
<p><b>Example 1: DOWHILE Command Group That is Never Processed</b>
</p>
<p>
<pre>
DCL VAR(&amp;LGL) TYPE(*LGL) VALUE('0') /* False */
:
DOWHILE COND(&amp;LGL)
: (group of CL commands)
ENDDO
:
</pre>
</p>
<p>The group of commands between the DOWHILE and ENDDO will not be processed because the initial value of &amp;LGL is false. Control will pass to the command following the ENDDO.
</p>
<p><b>Example 2: DOWHILE Forever Command Group</b>
</p>
<p>
<pre>
DCL VAR(&amp;LGL) TYPE(*LGL) VALUE('1') /* True */
:
DOWHILE &amp;LGL
: (group of CL commands)
ENDDO
:
</pre>
</p>
<p>The group of commands between the DOWHILE and ENDDO will be processed until the value of &amp;LGL is set to false (a logical 0). This loop will continue until a LEAVE command or a GOTO command specifying a label outside the DOWHILE group is run.
</p>
</div>
<table width="100%">
<tr><td align="right"><a href="#DOWHILE.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div><h3><a name="DOWHILE.ERROR.MESSAGES">Error messages</a> </h3>
<p>None
</p>
</div>
<table width="100%">
<tr><td align="right"><a href="#DOWHILE.Top_Of_Page">Top</a></td></tr>
</table>
</body>
</html>