112 lines
7.1 KiB
HTML
112 lines
7.1 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="SELECT command and SELECT groups" />
|
|
<meta name="abstract" content="The Select (SELECT) command is used to identify one or more conditions and an associated group of commands to process when that condition is true." />
|
|
<meta name="description" content="The Select (SELECT) command is used to identify one or more conditions and an associated group of commands to process when that condition is true." />
|
|
<meta name="DC.subject" content="SELECT (Select) command, command, CL, ENDSELECT (End Select) command, End Select (ENDSELECT) command, WHEN (When) command, OTHERWISE (Otherwise) command, command, CL, ENDSELECT (End Select), End Select (ENDSELECT), SELECT (Select), WHEN (When), OTHERWISE (Otherwise), example, SELECT command, ENDSELECT command" />
|
|
<meta name="keywords" content="SELECT (Select) command, command, CL, ENDSELECT (End Select) command, End Select (ENDSELECT) command, WHEN (When) command, OTHERWISE (Otherwise) command, command, CL, ENDSELECT (End Select), End Select (ENDSELECT), SELECT (Select), WHEN (When), OTHERWISE (Otherwise), example, SELECT command, ENDSELECT command" />
|
|
<meta name="DC.Relation" scheme="URI" content="contp.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../clfinder/finder.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../cl/select.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="selectcmd" />
|
|
<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>SELECT command and SELECT groups</title>
|
|
</head>
|
|
<body id="selectcmd"><a name="selectcmd"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">SELECT command and SELECT groups</h1>
|
|
<div><p>The <span class="cmdname">Select (SELECT)</span> command is used to identify
|
|
one or more conditions and an associated group of commands to process when
|
|
that condition is true. </p>
|
|
<div class="section"><p>A special group of commands may also be specified to be processed
|
|
when none of the stated conditions are true. Only one of the groups of commands
|
|
identified by <span class="cmdname">When (WHEN)</span> or <span class="cmdname">Otherwise (OTHERWISE)</span> commands
|
|
will be processed within the group.</p>
|
|
<p>The general structure of the <span class="cmdname">Select
|
|
(SELECT)</span> command is as follows:</p>
|
|
<pre>SELECT
|
|
WHEN (condition-1) THEN(command-1)
|
|
.
|
|
.
|
|
.
|
|
WHEN (condition-n) THEN(command-n)
|
|
OTHERWISE command-x
|
|
ENDSELECT</pre>
|
|
<p>A SELECT group must specify at least one <span class="cmdname">When (WHEN)</span> command.
|
|
The <span class="cmdname">When (WHEN)</span> command includes an expression, which
|
|
is tested (true or false), and an optional THEN parameter that specifies
|
|
the action to take if the condition is true.</p>
|
|
<p>The logical expression
|
|
on the COND parameter may be a single logical variable or constant, or it
|
|
must describe a relationship between two or more operands; the expression
|
|
is then evaluate as true or false.</p>
|
|
<p>If the condition described
|
|
by the logical expression is evaluated as true, the procedure processes the
|
|
CL command on the THEN parameter. This may be a single command or a group
|
|
of commands specified by the DO, DOWHILE, DOUNTIL, or DOFOR commands. If
|
|
the condition is not true, the condition specified on the next <span class="cmdname">When
|
|
(WHEN)</span> command in the SELECT group is evaluated. If there is no <span class="cmdname">When
|
|
(WHEN)</span> command following this one, the command identified by the <span class="cmdname">Otherwise
|
|
(OTHERWISE)</span> command, if any, is processed. If there is no next
|
|
WHEN and no <span class="cmdname">Otherwise (OTHERWISE)</span> command, processing continues
|
|
with the next command following the associated ENDSELECT command.</p>
|
|
<pre>SELECT
|
|
WHEN (&LGL)
|
|
WHEN (&INT *LT 0) THEN(CHGVAR &INT 0)
|
|
WHEN (&INT *GT 0) (DOUNTIL (&INT *EQ 0))
|
|
CHGVAR &INT (&INT - 1)
|
|
ENDDO
|
|
OTHERWISE (CHGVAR &LGL '1')
|
|
ENDSELECT</pre>
|
|
<p>If the initial value of &LGL is true ('1'), processing
|
|
continues with the command following the ENDSELECT, because there is no THEN
|
|
parameter.</p>
|
|
<p>If the initial value of &LGL is false ('0'), the COND
|
|
of the second WHEN is evaluated. If &INT is less than zero, the CHGVAR
|
|
is processed, setting the value of &INT to zero. Processing then continues
|
|
with the command following the ENDSELECT.</p>
|
|
<p>If the first two conditions
|
|
are not met, the value of &INT is checked to determine if it is greater
|
|
than zero. If the value is greater than zero, the DOUNTIL group is entered
|
|
and the value of &INT decremented until it reaches zero. When &INT
|
|
reaches zero, the DOUNTIL group is exited and processing continues with the
|
|
next command following the ENDSELECT.</p>
|
|
<p>If none of the conditions on any
|
|
of the <span class="cmdname">When (WHEN)</span> commands is evaluated as true, the CHGVAR
|
|
specified on the CMD parameter of the <span class="cmdname">Otherwise (OTHERWISE)</span> command
|
|
is processed. The value of &INT remains unchanged while &LGL is set
|
|
to true. Processing then continues with the next command following the ENDSELECT.</p>
|
|
</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="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/select.htm">Select (SELECT) command</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |