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

99 lines
3.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>Go To (GOTO)</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="GOTO.Top_Of_Page"></a>
<h2>Go To (GOTO)</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="#GOTO.PARAMETERS.TABLE">Parameters</a><br>
<a href="#GOTO.COMMAND.EXAMPLES">Examples</a><br>
<a href="#GOTO.ERROR.MESSAGES">Error messages</a></td>
</tr>
</table>
<div> <a name="GOTO"></a>
<p>The Go To (GOTO) command is used in CL procedures for branching from one part of the program to another. The branching is to the label on another command that is specified on the Go To (GOTO) command. Branching can be either forward or backward, but the specified label must be inside the program. For a GOTO command in a subroutine, the branch target must be associated with the same subroutine.
</p>
<p><b>Restrictions:</b>
</p>
<ul>
<li>This command is valid only within a CL procedure.
</li>
<li>Using GOTO to branch into or out of a subroutine is not allowed.
</li>
</ul>
</div>
<table width="100%">
<tr><td align="right"><a href="#GOTO.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div>
<h3><a name="GOTO.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="#GOTO.CMDLBL"><b>CMDLBL</b></a></td>
<td valign="top">Command label</td>
<td valign="top"><i>Simple name</i></td>
<td valign="top">Required, Positional 1</td>
</tr>
</table>
<table width="100%">
<tr><td align="right"><a href="#GOTO.Top_Of_Page">Top</a></td></tr>
</table>
</div>
<div> <a name="GOTO.CMDLBL"></a>
<h3>Command label (CMDLBL)</h3>
<p>Specifies the label name of the command to which control is transferred; when the Go To (GOTO) command is processed. The command with the label is then processed. If the specified command cannot be run (for example, if it is a DCL command), control is transferred to the next command following the command with the specified label. The label must be within the same program as the GOTO command. A CL variable name cannot be used to specify the label name.
</p>
<p>This is a required parameter.
</p>
</div>
<table width="100%">
<tr><td align="right"><a href="#GOTO.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div><h3><a name="GOTO.COMMAND.EXAMPLES">Examples</a> </h3>
<p>
<pre>
LOOP: CHGVAR &amp;A (&amp;A + 1)
IF (&amp;A *LT 30) THEN(GOTO LOOP)
</pre>
</p>
<p>The Change Variable (CHGVAR) command increases the value of &amp;A by 1 until &amp;A is equal to or greater than 30. The GOTO command is processed each time that the IF command tests the expression and the result is true; the GOTO command following the THEN parameter causes the procedure to branch back to the label LOOP on the CHGVAR command. Refer to the descriptions of the CHGVAR command and the IF command for additional explanations of their functions.
</p>
</div>
<table width="100%">
<tr><td align="right"><a href="#GOTO.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div><h3><a name="GOTO.ERROR.MESSAGES">Error messages</a> </h3>
<p>None
</p>
</div>
<table width="100%">
<tr><td align="right"><a href="#GOTO.Top_Of_Page">Top</a></td></tr>
</table>
</body>
</html>