<?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="ITERATE command" /> <meta name="abstract" content="The Iterate (ITERATE) command can be used to skip the remaining commands in an active DOWHILE, DOUNTIL, or DOFOR group." /> <meta name="description" content="The Iterate (ITERATE) command can be used to skip the remaining commands in an active DOWHILE, DOUNTIL, or DOFOR group." /> <meta name="DC.subject" content="ITERATE (Iterate) command, command, CL, ITERATE (Iterate), example, ITERATE command" /> <meta name="keywords" content="ITERATE (Iterate) command, command, CL, ITERATE (Iterate), example, ITERATE 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/iterate.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="iteratecmd" /> <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>ITERATE command</title> </head> <body id="iteratecmd"><a name="iteratecmd"><!-- --></a> <!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script> <h1 class="topictitle1">ITERATE command</h1> <div><p>The <span class="cmdname">Iterate (ITERATE)</span> command can be used to skip the remaining commands in an active DOWHILE, DOUNTIL, or DOFOR group. </p> <div class="section"><p>ITERATE is not valid with simple DO command groups.</p> <p>An <span class="cmdname">Iterate (ITERATE)</span> command without a label will skip to the ENDDO of the innermost active DO group. Specifying a label skips to the ENDDO of the DO associated with the label.</p> <p>The following illustrates use of the <span class="cmdname">Iterate (ITERATE)</span> command:</p> <pre>DO_1: DO_2:DOWHILE &LGL DO_3: DOFOR &INT FROM(0) TO(99) . . . IF (&A *EQ 12) THEN (ITERATE DO_1) . . /* Not processed if &A equals 12 */ . IF (&A *GT 12) ITERATE . . /* Not processed if &A greater than 12 */ . ENDDO . . . IF (&A *LT 0) (ITERATE DO_1) . . /* Not processed if &A less than zero */ . ENDDO </pre> <p>In this example, the labels DO_1 and DO_2 are associated with the DOWHILE group. They can be specified on an <span class="cmdname">Iterate (ITERATE)</span> command appearing in either the DOWHILE or DOFOR group. When &A is equal to 12, the ITERATE DO_1 command is run. Processing continues at the ENDDO associated with the DOWHILE command. The value of &LGL is evaluated and, if true, continues with the DOFOR following the DOWHILE. If &LGL is false, processing continues with the CL command following the second ENDDO.</p> <p>If &A is not equal to 12 but is greater than 12, processing continues with the ENDDO of the DOFOR group. The value of &INT is incremented and compared to the ending value of 99. If &INT is less than or equal to 99, processing continues with the first command following the <span class="cmdname">Do For (DOFOR)</span> command. If &INT is greater than 99, processing continues with the next command following the first ENDDO.</p> <p>When the third IF command is processed and &A is less than zero, processing continues with the second ENDDO. The value of &LGL is evaluated and, if false, control passes to the command following the ENDDO. If true, processing resumes with the <span class="cmdname">Do For (DOFOR)</span> command following the DOWHILE.</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="relinfo"><strong>Related information</strong><br /> <div><a href="../clfinder/finder.htm">CL command finder</a></div> <div><a href="../cl/iterate.htm">Iterate (ITERATE) command</a></div> </div> </div> </body> </html>