118 lines
6.5 KiB
HTML
118 lines
6.5 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="ELSE command" />
|
|
<meta name="abstract" content="The ELSE command is a way of specifying alternative processing if the condition on the associated IF command is false." />
|
|
<meta name="description" content="The ELSE command is a way of specifying alternative processing if the condition on the associated IF command is false." />
|
|
<meta name="DC.subject" content="ELSE (Else) command, command, CL" />
|
|
<meta name="keywords" content="ELSE (Else) command, command, CL" />
|
|
<meta name="DC.Relation" scheme="URI" content="contp.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="ifcmd.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../clfinder/finder.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../cl/else.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="expr.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="elsec" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>ELSE command</title>
|
|
</head>
|
|
<body id="elsec"><a name="elsec"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">ELSE command</h1>
|
|
<div><p>The ELSE command is a way of specifying alternative processing
|
|
if the condition on the associated IF command is false.</p>
|
|
<div class="section"><p>The IF command can be used without the ELSE command: </p>
|
|
<pre>IF (&A=&B) THEN(CALLPRC PROCA)
|
|
CALLPRC PROCB</pre>
|
|
<p>In this case, PROCA is called only if <samp class="codeph">&A=&B</samp>,
|
|
but PROCB is always called.</p>
|
|
<p>If you use an ELSE command in this procedure,
|
|
however, the processing logic changes. In the following example, if <samp class="codeph">&A=&B</samp>,
|
|
PROCA is called, and PROCB is not called. If the expression <samp class="codeph">&A=&B</samp> is
|
|
not true, PROCB is called. </p>
|
|
<pre>IF (&A=&B) THEN(CALLPRC PROCA)
|
|
ELSE CMD(CALLPRC PROCB)
|
|
CHGVAR &C 8</pre>
|
|
<p>The ELSE command must be used when a false evaluation of an
|
|
IF expression leads to a distinct branch (that is, an exclusive either/or
|
|
branch).</p>
|
|
<p>The real usefulness of the ELSE command is best demonstrated
|
|
when combined with Do groups. In the following example, the Do group may
|
|
not be run, depending on the evaluation of the IF expression, but the remaining
|
|
commands are always processed.</p>
|
|
<div class="fignone"><br /><img src="rslf157.gif" alt="The real usefulness of the ELSE command is best demonstrated when combined with Do groups. In this example, the Do group may not be run, depending on the evaluation of the IF expression, but the remaining commands are always processed." /><br /></div>
|
|
<p>With the ELSE command you can specify that a command or set of commands
|
|
be processed only if the expression is not true, thus completing the logical
|
|
alternatives:</p>
|
|
<div class="fignone"><br /><img src="rv2w275.gif" alt="With the ELSE command you can specify that a command or set of commands be processed only if the expression is not true, thus completing the logical alternatives" /><br /></div>
|
|
<p>Each ELSE command must have an associated IF command preceding it.
|
|
If nested levels of IF commands are present, each ELSE command is matched
|
|
with the innermost IF command that has not already been matched with another
|
|
ELSE command. </p>
|
|
<pre>IF ... THEN ...
|
|
IF ...THEN(DO)
|
|
IF ...THEN(DO)
|
|
.
|
|
.
|
|
.
|
|
ENDDO
|
|
ELSE DO
|
|
IF ...THEN(DO)
|
|
.
|
|
.
|
|
.
|
|
ENDDO
|
|
ELSE DO
|
|
.
|
|
.
|
|
.
|
|
ENDDO
|
|
ENDDO
|
|
ELSE IF ... THEN ...
|
|
IF ... THEN ...
|
|
IF ... THEN ...</pre>
|
|
<p>In reviewing your procedure for matched ELSE commands, always
|
|
start with the innermost set.</p>
|
|
<p>The ELSE command can be used to test a
|
|
series of mutually exclusive options. In the following example, after the
|
|
first successful IF test, the embedded command is processed and the procedure
|
|
processes the <span class="cmdname">Reclaim Resources (RCLRSC)</span> command:
|
|
</p>
|
|
<pre>IF COND(&OPTION=1) THEN(CALLPRC PRC(ADDREC))
|
|
ELSE CMD(IF COND(&OPTION=2) THEN(CALLPRC PRC(DSPFILE)))
|
|
ELSE CMD(IF COND(&OPTION=3) THEN(CALLPRC PRC(PRINTFILE)))
|
|
ELSE CMD(IF COND(&OPTION=4) THEN(CALLPRC PRC(DUMP)))
|
|
RCLRSC
|
|
RETURN</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="contp.htm" title="You can use commands to change the flow of logic within your CL procedure.">Control processing within a CL procedure</a></div>
|
|
</div>
|
|
<div class="relref"><strong>Related reference</strong><br />
|
|
<div><a href="ifcmd.htm" title="The IF command is used to state a condition that, if true, specifies some statement or group of statements in the procedure to be run.">IF command</a></div>
|
|
<div><a href="expr.htm" title="The logical operators *AND and *OR specify the relationship between operands in a logical expression. The logical operator *NOT is used to negate logical variables or constants.">*AND, *OR, and *NOT operators</a></div>
|
|
</div>
|
|
<div class="relinfo"><strong>Related information</strong><br />
|
|
<div><a href="../clfinder/finder.htm">CL command finder</a></div>
|
|
<div><a href="../cl/else.htm">Else (ELSE) command</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |