162 lines
5.8 KiB
HTML
162 lines
5.8 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>Else (ELSE)</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="ELSE.Top_Of_Page"></a>
|
||
|
<h2>Else (ELSE)</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="#ELSE.PARAMETERS.TABLE">Parameters</a><br>
|
||
|
<a href="#ELSE.COMMAND.EXAMPLES">Examples</a><br>
|
||
|
<a href="#ELSE.ERROR.MESSAGES">Error messages</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<div> <a name="ELSE"></a>
|
||
|
<p>The Else (ELSE) command is used with an IF command to specify another command that is to be conditionally processed. The ELSE command is processed only if the result of evaluating the logical expression on the preceding IF command is false. If the result is true, the ELSE command and commands associated with it are not processed.
|
||
|
</p>
|
||
|
<p>The ELSE command can specify a CL command, or a Do group, to be processed for the false condition.
|
||
|
</p>
|
||
|
<p>An ELSE command does not have to follow each IF command, but each ELSE command that is coded must have an associated IF command preceding it. If nested levels of IF commands are used, a given ELSE is always matched with the innermost IF command that has not already been matched with another ELSE command. Although the ELSE command is optional, coding all of the matching ELSE commands makes it easier to see where all of the nesting levels start and end.
|
||
|
</p>
|
||
|
<p><b>Restrictions:</b> The ELSE command is valid only in a CL procedure. It must have an associated IF command preceding it.
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#ELSE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<hr size="2" width="100%">
|
||
|
|
||
|
<div>
|
||
|
<h3><a name="ELSE.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="#ELSE.CMD"><b>CMD</b></a></td>
|
||
|
<td valign="top">Command</td>
|
||
|
<td valign="top"><i>Command string</i></td>
|
||
|
<td valign="top">Optional, Positional 1</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#ELSE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div> <a name="ELSE.CMD"></a>
|
||
|
<h3>Command (CMD)</h3>
|
||
|
<p>Specifies the command or commands (in a Do group) to be processed if the result of evaluating the expression on the corresponding IF command is false.
|
||
|
</p>
|
||
|
<p>If the command specified in this parameter is a DO command, all of the commands specified within the Do group are considered to be part of the command specified by the parameter. If no command is specified, no action is taken for a false condition.
|
||
|
</p>
|
||
|
<p>If the command specified by the CMD keyword is not coded on the same line as the keyword, the left parenthesis following CMD must be coded on the same line, followed by a + or - to show continuation. The command and the right parenthesis can then be coded on the next line. For example:
|
||
|
</p>
|
||
|
<p>
|
||
|
<pre>
|
||
|
ELSE CMD( +
|
||
|
GOTO C)
|
||
|
</pre>
|
||
|
</p>
|
||
|
<p>If any part of the command continues on the next line, a continuation character (+ or -) must be specified.
|
||
|
</p>
|
||
|
<p>If a DO command is specified, only the DO command (not the commands specified as part of the Do group) is placed in parentheses. For example:
|
||
|
</p>
|
||
|
<p>
|
||
|
<pre>
|
||
|
ELSE CMD(DO)
|
||
|
CMD1
|
||
|
CMD2
|
||
|
.
|
||
|
.
|
||
|
.
|
||
|
ENDDO
|
||
|
</pre>
|
||
|
</p>
|
||
|
<p>The following commands, although valid in CL procedures, cannot be specified on the ELSE command:
|
||
|
</p>
|
||
|
<ul>
|
||
|
<li>ENDDO (End Do)
|
||
|
</li>
|
||
|
<li>MONMSG (Monitor Message)
|
||
|
</li>
|
||
|
<li>PGM (Program)
|
||
|
</li>
|
||
|
<li>ENDPGM (End Program)
|
||
|
</li>
|
||
|
<li>DCL (Declare CL Variable)
|
||
|
</li>
|
||
|
<li>DCLF (Declare File)
|
||
|
</li>
|
||
|
<li>another ELSE command
|
||
|
</li>
|
||
|
<li>WHEN, OTHERWISE, ENDSELECT
|
||
|
</li>
|
||
|
</ul>
|
||
|
<p>In addition, the MONMSG command cannot be specified as the next command after the ELSE command.
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#ELSE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<hr size="2" width="100%">
|
||
|
<div><h3><a name="ELSE.COMMAND.EXAMPLES">Examples</a> </h3>
|
||
|
<p><b>Example 1: Using ELSE and IF Commands</b>
|
||
|
</p>
|
||
|
<p>
|
||
|
<pre>
|
||
|
IF (&A *GT &B) THEN(CHGVAR VAR(&A) VALUE(&B))
|
||
|
ELSE (CHGVAR &B &A)
|
||
|
</pre>
|
||
|
</p>
|
||
|
<p>If the value of &A is greater than the value of &B, &A is set equal to &B. If &A is less than or equal to &B, the test result is false. The CHGVAR command on the ELSE command is processed, and the value of &B is set to the same value as &A. (Refer to the CHGVAR (Change Variable) command for the description of the command and its parameters.)
|
||
|
</p>
|
||
|
<p><b>Example 2: Nested Levels of Commands</b>
|
||
|
</p>
|
||
|
<p>
|
||
|
<pre>
|
||
|
IF COND(&A *EQ &B) +
|
||
|
THEN(IF (&C *EQ &D) +
|
||
|
THEN(IF (&C *EQ &F) THEN(DO)))
|
||
|
CMD1
|
||
|
CMD2
|
||
|
:
|
||
|
ENDDO
|
||
|
ELSE CMDX
|
||
|
ELSE CMDY
|
||
|
ELSE DO
|
||
|
</pre>
|
||
|
</p>
|
||
|
<p>This example shows the use of nested levels of IF commands where an ELSE command is associated with each IF. The use of the ELSE commands makes the nested levels of IF commands easier to identify.
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#ELSE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<hr size="2" width="100%">
|
||
|
<div><h3><a name="ELSE.ERROR.MESSAGES">Error messages</a> </h3>
|
||
|
<p>None
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#ELSE.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
</body>
|
||
|
</html>
|