ibm-information-center/dist/eclipse/plugins/i5OS.ic.rbam6_5.4.0.1/condp.htm

180 lines
11 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?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="concept" />
<meta name="DC.Title" content="Conditional prompting" />
<meta name="abstract" content="You can specify that a parameter is prompted for only when certain conditions are met." />
<meta name="description" content="You can specify that a parameter is prompted for only when certain conditions are met." />
<meta name="DC.subject" content="conditional prompting, prompting, conditional" />
<meta name="keywords" content="conditional prompting, prompting, conditional" />
<meta name="DC.Relation" scheme="URI" content="pmtc.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="condp" />
<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>Conditional prompting</title>
</head>
<body id="condp"><a name="condp"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Conditional prompting</h1>
<div><p>You can specify that a parameter is prompted for only when certain
conditions are met.</p>
<p>When prompting the user for a command, a parameter that is conditioned
by other parameters is displayed if: </p>
<ul><li>It is selected by the value specified for the controlling parameter.</li>
<li>The value specified for the controlling parameter is in error.</li>
<li>A value was specified for the conditioned parameter.</li>
<li>A function key was pressed during prompting to request that all parameters
be displayed.</li>
</ul>
<p>When a user is to be prompted for a conditioned parameter and no value
has yet been specified for its controlling parameter, all parameters previously
selected are displayed. When the user presses the Enter key, the controlling
parameter is then tested to determine if the conditioned parameter should
be displayed or not.</p>
<p>To specify conditional prompting in the command definition source, specify
a label name in the PMTCTL parameter on the PARM statement for each parameter
that is conditioned by another parameter. The label specified must be defined
on a PMTCTL statement which specifies the controlling parameter and the condition
being tested to select the parameter for prompting. More than one PARM statement
can refer to the same label.</p>
<p>On the PMTCTL statement, specify the name of the controlling parameter,
one or more conditions to be tested, and the number of conditions that must
be true to select the conditioned parameters for prompting. If the controlling
parameter has special value mapping, the value entered on the PMTCTL statement
must be the to-value. If the controlling parameter is a list or qualified
name, only the first list item or qualifier is compared.</p>
<div class="p">In the following example, parameters OUTFILE and OUTMBR is selected only
if *OUTFILE is specified for the OUTPUT parameter, and parameter OUTQ is selected
only if *PRINT is specified for the OUTPUT parameter. <pre> PARM OUTPUT TYPE(*CHAR) LEN(1) DFT(*) RSTD(*YES) +
SPCVAL((*) (*PRINT P) (*OUTFILE F))
PARM OUTFILE TYPE(Q1) PMTCTL(OUTFILE)
PARM OUTMBR TYPE(*NAME) LEN(10) PMTCTL(OUTFILE)
PARM OUTLINK TYPE(*CHAR) LEN(10)
PARM OUTQ TYPE(Q1) PMTCTL(PRINT)
Q1: QUAL TYPE(*NAME) LEN(10)
QUAL TYPE(*NAME) LEN(10) SPCVAL(*LIBL) DFT(*LIBL)
OUTFILE: PMTCTL CTL(OUTPUT) COND((*EQ F)) NBRTRUE(*EQ 1)
PRINT: PMTCTL CTL(OUTPUT) COND((*EQ P)) NBRTRUE(*EQ 1)</pre>
</div>
<p>In this previous example, the user is prompted for the OUTLINK parameter
after the condition for OUTMBR parameter has been tested. In some cases,
the user should be prompted for the OUTLINK parameter before the OUTMBR parameter
is tested. To specify a different prompt order, either reorder the parameters
in the command definition source or use the PROMPT keyword on the PARM statement
for the OUTLINK parameter.</p>
<p>A label can refer to a group of PMTCTL statements. This allows you to
condition a parameter with more than one controlling parameter. To specify
a group of PMTCTL statements, enter the label on the first statement in the
group. No other statements can be placed between the PMTCTL statements in
the group.</p>
<p>Use the LGLREL parameter to specify the logical relationship between the
statements in the group. The LGLREL parameter is not allowed on the first
PMTCTL statement in a group. For subsequent PMTCTL statements, the LGLREL
parameter specifies the logical relationship (*AND or *OR) to the PMTCTL statement
or statements preceding it. Statements in a group can be logically related
in any combination of *AND and *OR relationships (*AND relationships are
checked first, then *OR relationships).</p>
<p>The following example shows how the logical relationship is used to group
multiple PMTCTL statements. In this example, parameter P3 is selected when
any one of the following conditions exists: </p>
<ul><li>*ALL is specified for P1.</li>
<li>*SOME is specified for P1 and *ALL is specified for P2.</li>
<li>*NONE is specified for P1 and *ALL is not specified for P2.</li>
</ul>
<pre>PARM P1 TYPE(*CHAR) LEN(5) RSTD(*YES) VALUES(*ALL *SOME *NONE)
PARM P2 TYPE(*NAME) LEN(10) SPCVAL(*ALL)
PARM P3 TYPE(*CHAR) LEN(10) PMTCTL(PMTCTL1)
PMTCTL1:PMTCTL CTL(P1) COND((*EQ *ALL))
PMTCTL CTL(P1) COND((*EQ *SOME)) LGLREL(*OR)
PMTCTL CTL(P2) COND((*EQ *ALL)) LGLREL(*AND)
PMTCTL CTL(P1) COND((*EQ *NONE)) LGLREL(*OR)
PMTCTL CTL(P2) COND((*NE *ALL)) LGLREL(*AND)</pre>
<p>An exit program can be specified to perform additional processing on a
controlling parameter before it is tested. The exit program can be used to
condition prompting based on: </p>
<ul><li>The type or other attribute of an object</li>
<li>A list item or qualifier other than the first one</li>
<li>An entire list or qualified name</li>
</ul>
<p>To specify an exit program, specify the qualified name of the program in
the PMTCTLPGM parameter on the PARM statement for the controlling parameter.
The exit program is run during prompting when checking a parameter. The conditions
on the PMTCTL statement are compared with the value returned by the exit program
rather than the value specified for the controlling parameter.</p>
<p>When the system cannot find or successfully run the exit program, the system
assumes any conditions that would use the returned value as true.</p>
<p>The exit program must be written to accept three parameters:</p>
<ul><li>A 20-character field. The prompter passes the name of the command in
the first 10 characters and the name of the controlling parameter in the last
10 characters. This field should not be changed.</li>
<li>The value of the controlling parameter. This field is in the same format
as it is when passed to the command processing program and should not be changed.</li>
<li>If the controlling parameter is defined as VARY(*YES) the value is not
preceded by a length value. If the controlling parameter is PASSATR(*YES),
the attribute byte is not included.</li>
<li>A 32-character field into which the exit program places the value to be
tested in the PMTCTL statements. <p>The value being tested in the PMTCTL
statement must be returned in the same format as the declared data type.</p>
</li>
</ul>
<p>In the following example, OBJ is a qualified name which may be the name
of a command, program, or file. The exit program determines the object type
and returns the type in the variable &amp;RTNVAL:</p>
<pre>CMD
PARM OBJ TYPE(Q1) PMTCTLPGM(CNVTYPE)
Q1: QUAL TYPE(*NAME) LEN(10)
QUAL TYPE(*NAME) LEN(10) SPCVAL(*LIBL) DFT(*LIBL)
PARM CMDPARM TYPE(*CHAR) LEN(10) PMTCTL(CMD)
PARM PGMPARM TYPE(*CHAR) LEN(10) PMTCTL(PGM)
PARM FILEPARM TYPE(*CHAR) LEN(10) PMTCTL(FILE)
CMD: PMTCTL CTL(OBJ) COND((*EQ *CMD) (*EQ *)) NBRTRUE(*EQ 1)
PGM: PMTCTL CTL(OBJ) COND((*EQ *PGM) (*EQ *)) NBRTRUE(*EQ 1)
FILE: PMTCTL CTL(OBJ) COND((*EQ *FILE) (*EQ *)) NBRTRUE(*EQ 1)</pre>
<p>The source for the exit program is shown here:</p>
<div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code license and disclaimer information</a> for important legal
information.</div>
<pre>PGM PARM(&amp;CMD &amp;PARMVAL &amp;RTNVAL)
DCL &amp;CMD *CHAR 20 /* Command and parameter name */
DCL &amp;PARMVAL *CHAR 20 /* Parameter value */
DCL &amp;RTNVAL *CHAR 32 /* Return value */
DCL &amp;OBJNAM *CHAR 10 /* Object name */
DCL &amp;OBJLIB *CHAR 10 /* Object type */
CHGVAR &amp;OBJNAM %SST(&amp;PARMVAL 1 10)
CHGVAR &amp;OBJLIB %SST(&amp;PARMVAL 11 10)
CHGVAR &amp;RTNVAL '*' /* Initialize return value to error*/
CHKOBJ &amp;OBJLIB/&amp;OBJNAM *CMD /* See if command exists */
MONMSG CPF9801 EXEC(GOTO NOTCMD) /* Skip if no command */
CHGVAR &amp;RTNVAL '*CMD' /* Indicate object is a command */
RETURN /* Exit */
NOTCMD:
CHKOBJ &amp;OBJLIB/&amp;OBJNAM *PGM /* See if program exists */
MONMSG CPF9801 EXEC(GOTO NOTPGM) /* Skip if no program */
CHGVAR &amp;RTNVAL '*PGM' /* Indicate object is a program */
RETURN /* Exit */
NOTPGM:
CHKOBJ &amp;OBJLIB/&amp;OBJNAM *FILE /* See if file exists */
MONMSG CPF9801 EXEC(RETURN) /* Exit if no file */
CHGVAR &amp;RTNVAL '*FILE' /* Indicate object is a file */
ENDPGM</pre>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="pmtc.htm" title="You can control which parameters are displayed for a command during prompting by using prompt control specifications.">Use prompt control</a></div>
</div>
</div>
</body>
</html>