<?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="%SWITCH with the IF command" /> <meta name="abstract" content="On the If (IF) command, %SWITCH can be specified on the COND parameter as the logical expression to be tested." /> <meta name="description" content="On the If (IF) command, %SWITCH can be specified on the COND parameter as the logical expression to be tested." /> <meta name="DC.subject" content="IF (If) command, using %SWITCH with, example, switch function" /> <meta name="keywords" content="IF (If) command, using %SWITCH with, example, switch function" /> <meta name="DC.Relation" scheme="URI" content="switc.htm" /> <meta name="DC.Relation" scheme="URI" content="../cl/if.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="ifcd" /> <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>%SWITCH with the IF command</title> </head> <body id="ifcd"><a name="ifcd"><!-- --></a> <!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script> <h1 class="topictitle1">%SWITCH with the IF command</h1> <div><p>On the <span class="cmdname">If (IF)</span> command, %SWITCH can be specified on the COND parameter as the logical expression to be tested.</p> <div class="section"><p>In the following example, <samp class="codeph">0X111XX0</samp> is compared to the predetermined job switch setting: </p> <pre>IF COND(%SWITCH(0X111XX0)) THEN(GOTO C)</pre> <p>If job switches 1, 3, 4, 5, and 8 contain 0, 1, 1, 1, and 0, respectively, the result is true and the procedure branches to the command having the label C. If one or more of the switches tested do not have the values indicated in the mask, the result is false, and the branch does not occur.</p> <p>In the following example, switches control conditional processing in two procedures. </p> <pre>SBMJOB JOB(APP502) JOBD(PAYROLL) CMD(CALL APP502) SWS(11000000) PGM /* CONTROL */ IF (%SWITCH(11XXXXXX)) CALLPRC PROCA IF (%SWITCH(10XXXXXX)) CALLPRC PROCB IF (%SWITCH(01XXXXXX)) CALLPRC PROCC IF (%SWITCH(00XXXXXX)) CALLPRC PROCD ENDPGM PGM /* PROCA */ CALLPRC TRANS IF (%SWITCH(1XXXXXXX)) CALLPRC CUS520 ELSE CALLPRC CUS521 ENDPGM</pre> </div> </div> <div> <div class="familylinks"> <div class="parentlink"><strong>Parent topic:</strong> <a href="switc.htm" title="The switch built-in function (%SWITCH) compares one or more of eight switches with the eight switch settings already established for the job and returns a logical value of '0' or '1'.">%SWITCH built-in function</a></div> </div> <div class="relinfo"><strong>Related information</strong><br /> <div><a href="../cl/if.htm">If (IF) command</a></div> </div> </div> </body> </html>