184 lines
10 KiB
HTML
184 lines
10 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="task" />
|
||
|
<meta name="DC.Title" content="Change the value of a variable" />
|
||
|
<meta name="abstract" content="You can change the value of a CL variable using the Change Variable (CHGVAR) command." />
|
||
|
<meta name="description" content="You can change the value of a CL variable using the Change Variable (CHGVAR) command." />
|
||
|
<meta name="DC.subject" content="example, changing, variable value, CHGVAR (Change Variable) command, Change Variable (CHGVAR) command, command, CL, CHGVAR (Change Variable), Change Variable (CHGVAR), variable, value of" />
|
||
|
<meta name="keywords" content="example, changing, variable value, CHGVAR (Change Variable) command, Change Variable (CHGVAR) command, command, CL, CHGVAR (Change Variable), Change Variable (CHGVAR), variable, value of" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="workv.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rbam6addr.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rbam6offset.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="subst.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="switc.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="binar.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../cl/chgvar.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="valuv" />
|
||
|
<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>Change the value of a variable</title>
|
||
|
</head>
|
||
|
<body id="valuv"><a name="valuv"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Change the value of a variable</h1>
|
||
|
<div><p>You can change the value of a CL variable using the <span class="cmdname">Change
|
||
|
Variable (CHGVAR)</span> command. </p>
|
||
|
<div class="section"> <p>The value can be changed: </p>
|
||
|
<ul><li>To a constant, shown in this example: <pre>CHGVAR VAR(&INVCMPLT) VALUE(0)</pre>
|
||
|
<p>&INVCMPLT is set to 0.</p>
|
||
|
<p>You could also use this notation:</p>
|
||
|
<pre>CHGVAR &INVCMPLT 0</pre>
|
||
|
</li>
|
||
|
<li>To the value of another variable, shown in this example: <pre>CHGVAR VAR(&A) VALUE(&B)</pre>
|
||
|
<p>&A is set to the value of the variable &B</p>
|
||
|
<p>You
|
||
|
could also use this notation</p>
|
||
|
<pre>CHGVAR &A &B</pre>
|
||
|
</li>
|
||
|
<li>To the value of an expression after it is evaluated, shown in the following
|
||
|
example: <pre>CHGVAR VAR(&A) VALUE(&A + 1)</pre>
|
||
|
<p>The value of &A is increased by 1.</p>
|
||
|
<p>You could also
|
||
|
use this notation:</p>
|
||
|
<pre>CHGVAR &A (&A + 1)</pre>
|
||
|
</li>
|
||
|
<li>To the value produced by the built-in function %SST, shown in the following
|
||
|
example: <pre>CHGVAR VAR(&A) VALUE(%SST(&B 1 5))</pre>
|
||
|
<p>&A is set to the first five characters of the value of
|
||
|
the variable &B</p>
|
||
|
</li>
|
||
|
<li>To the value produced by the built-in function %SWITCH, shown in the following
|
||
|
example: <pre>CHGVAR VAR(&A) VALUE(%SWITCH(0XX111X0))</pre>
|
||
|
<p>&A is set to 1 if job switches 1 and 8 are 0 and job switches
|
||
|
4, 5 and 6 are 1; otherwise, &A is set to 0.</p>
|
||
|
</li>
|
||
|
<li>To the value produced by the built-in function %BIN: <pre>CHGVAR VAR(&A) VALUE(%BIN((%B 1 4))</pre>
|
||
|
<p>The first four characters of variable &B are converted
|
||
|
to the decimal equivalent and stored in variable &A.</p>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<p>The CHGVAR command can be used to retrieve and to change the local
|
||
|
data area also. For example, the following commands blank out 10 bytes of
|
||
|
the local data area and retrieve part of the local data area: </p>
|
||
|
<pre>CHGVAR %SST(*LDA 1 10) ' '
|
||
|
|
||
|
CHGVAR &A %SST(*LDA 1 10)</pre>
|
||
|
<p>The following table shows valid assignments to variables from
|
||
|
values (literals or variables).</p>
|
||
|
|
||
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><caption>Table 1. Valid assignments to variables
|
||
|
from values</caption><thead align="left"><tr><th align="left" valign="bottom" id="d0e132"> </th>
|
||
|
<th align="left" valign="bottom" id="d0e133">Logical Value</th>
|
||
|
<th align="left" valign="bottom" id="d0e135">Character Value</th>
|
||
|
<th align="left" valign="bottom" id="d0e137">Decimal Value</th>
|
||
|
<th align="left" valign="bottom" id="d0e139">Signed Integer Value</th>
|
||
|
<th align="left" valign="bottom" id="d0e141">Unsigned Integer Value</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody><tr><td valign="top" headers="d0e132 "><strong>Logical Variable</strong></td>
|
||
|
<td valign="top" headers="d0e133 ">X</td>
|
||
|
<td valign="top" headers="d0e135 "> </td>
|
||
|
<td valign="top" headers="d0e137 "> </td>
|
||
|
<td valign="top" headers="d0e139 "> </td>
|
||
|
<td valign="top" headers="d0e141 "> </td>
|
||
|
</tr>
|
||
|
<tr><td valign="top" headers="d0e132 "><strong>Character Variable</strong></td>
|
||
|
<td valign="top" headers="d0e133 ">X</td>
|
||
|
<td valign="top" headers="d0e135 ">X</td>
|
||
|
<td valign="top" headers="d0e137 ">X</td>
|
||
|
<td valign="top" headers="d0e139 ">X</td>
|
||
|
<td valign="top" headers="d0e141 ">X</td>
|
||
|
</tr>
|
||
|
<tr><td valign="top" headers="d0e132 "><strong>Decimal Variable</strong></td>
|
||
|
<td valign="top" headers="d0e133 "> </td>
|
||
|
<td valign="top" headers="d0e135 ">X</td>
|
||
|
<td valign="top" headers="d0e137 ">X</td>
|
||
|
<td valign="top" headers="d0e139 ">X</td>
|
||
|
<td valign="top" headers="d0e141 ">X</td>
|
||
|
</tr>
|
||
|
<tr><td valign="top" headers="d0e132 "><strong>Signed Integer Variable</strong></td>
|
||
|
<td valign="top" headers="d0e133 "> </td>
|
||
|
<td valign="top" headers="d0e135 ">X</td>
|
||
|
<td valign="top" headers="d0e137 ">X</td>
|
||
|
<td valign="top" headers="d0e139 ">X</td>
|
||
|
<td valign="top" headers="d0e141 ">X</td>
|
||
|
</tr>
|
||
|
<tr><td valign="top" headers="d0e132 "><strong>Unsigned Integer Variable</strong></td>
|
||
|
<td valign="top" headers="d0e133 "> </td>
|
||
|
<td valign="top" headers="d0e135 ">X</td>
|
||
|
<td valign="top" headers="d0e137 ">X</td>
|
||
|
<td valign="top" headers="d0e139 ">X</td>
|
||
|
<td valign="top" headers="d0e141 ">X</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class="note"><span class="notetitle">Note:</span> <ol><li> <p>When specifying a numeric value for a character variable, remember
|
||
|
the following: </p>
|
||
|
<ul><li>The value of the character variable is right-justified and, if necessary,
|
||
|
padded with leading zeros.</li>
|
||
|
<li>The character variable must be long enough to contain a decimal point
|
||
|
and a minus (-) sign, when necessary.</li>
|
||
|
<li>When used, a minus (-) sign is placed in the leftmost position of the
|
||
|
value.</li>
|
||
|
</ul>
|
||
|
<p>For example, &A is a character variable to be changed to the value
|
||
|
of the decimal variable &B. The length of &A is 6. The length and
|
||
|
decimal positions of &B are 5 and 2, respectively. The current value
|
||
|
of &B is <samp class="codeph">123</samp>. The resulting value of &A is <samp class="codeph">123.00</samp>.</p>
|
||
|
</li>
|
||
|
<li> <p>When specifying a character value for a numeric variable, remember
|
||
|
the following: </p>
|
||
|
<ul><li>The decimal point is determined by the placement of a decimal point in
|
||
|
the character value. If the character value does not contain a decimal point,
|
||
|
the decimal point is placed in the rightmost position of the value.</li>
|
||
|
<li>The character value can contain a minus (-) sign or plus (+) sign immediately
|
||
|
to the left of the value; no intervening blanks are allowed. If the character
|
||
|
value has no sign, the value is assumed to be positive.</li>
|
||
|
<li>If the character value contains more digits to the right of the decimal
|
||
|
point than can be contained in the numeric variable, the digits are truncated
|
||
|
if it's a decimal variable, or rounded if it's an integer variable. If the
|
||
|
excess digits are to the left of the decimal point, they are not truncated
|
||
|
and an error occurs. <p>For example, &C is a decimal variable to be changed
|
||
|
to the value of the character variable &D The length of &C is 5 with
|
||
|
2 decimal positions. The length of &D is 10 and its current value is
|
||
|
+123.1bbbb (where b=blank). The resulting value of &C is <samp class="codeph">123.10</samp>.</p>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ol>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="workv.htm" title="CL procedures consist of CL commands, and the commands themselves consist of the command statement, parameters, and parameter values.">Use variables</a></div>
|
||
|
</div>
|
||
|
<div class="relref"><strong>Related reference</strong><br />
|
||
|
<div><a href="rbam6addr.htm" title="The address built-in function (%ADDRESS or %ADDR) can be used to change or test the memory address stored in a CL pointer variable and can only be used within a CL procedure.">%ADDRESS built-in function</a></div>
|
||
|
<div><a href="rbam6offset.htm" title="The offset built-in function (%OFFSET or %OFS) can be used to store or change the offset portion of a CL pointer variable and can only be used within a CL procedure.">%OFFSET built-in function</a></div>
|
||
|
<div><a href="subst.htm" title="The substring built-in function (%SUBSTRING or%SST) produces a character string that is a subset of an existing character string and can only be used within a CL procedure.">%SUBSTRING built-in function</a></div>
|
||
|
<div><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><a href="binar.htm" title="The binary built-in function (%BINARY or %BIN) interprets the contents of a specified CL character variable as a signed binary integer.">%BINARY built-in function</a></div>
|
||
|
</div>
|
||
|
<div class="relinfo"><strong>Related information</strong><br />
|
||
|
<div><a href="../cl/chgvar.htm">Change Variable (CHGVAR) command</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|