summaryrefslogtreecommitdiffstats
path: root/doc/groff.html.node/Setting-Registers.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/groff.html.node/Setting-Registers.html')
-rw-r--r--doc/groff.html.node/Setting-Registers.html215
1 files changed, 215 insertions, 0 deletions
diff --git a/doc/groff.html.node/Setting-Registers.html b/doc/groff.html.node/Setting-Registers.html
new file mode 100644
index 0000000..6fdf746
--- /dev/null
+++ b/doc/groff.html.node/Setting-Registers.html
@@ -0,0 +1,215 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by GNU Texinfo 7.0.3, https://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<!-- This manual documents GNU troff version 1.23.0.
+
+Copyright © 1994-2023 Free Software Foundation, Inc.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.3 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
+copy of the license is included in the section entitled "GNU Free
+Documentation License". -->
+<title>Setting Registers (The GNU Troff Manual)</title>
+
+<meta name="description" content="Setting Registers (The GNU Troff Manual)">
+<meta name="keywords" content="Setting Registers (The GNU Troff Manual)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="makeinfo">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="index.html" rel="start" title="Top">
+<link href="Request-Index.html" rel="index" title="Request Index">
+<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
+<link href="Registers.html" rel="up" title="Registers">
+<link href="Interpolating-Registers.html" rel="next" title="Interpolating Registers">
+<link href="Registers.html" rel="prev" title="Registers">
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+div.example {margin-left: 3.2em}
+span.r {font-family: initial; font-weight: normal; font-style: normal}
+span:hover a.copiable-link {visibility: visible}
+strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<div class="subsection-level-extent" id="Setting-Registers">
+<div class="nav-panel">
+<p>
+Next: <a href="Interpolating-Registers.html" accesskey="n" rel="next">Interpolating Registers</a>, Previous: <a href="Registers.html" accesskey="p" rel="prev">Registers</a>, Up: <a href="Registers.html" accesskey="u" rel="up">Registers</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Request-Index.html" title="Index" rel="index">Index</a>]</p>
+</div>
+<hr>
+<h4 class="subsection" id="Setting-Registers-1">5.8.1 Setting Registers</h4>
+<a class="index-entry-id" id="index-setting-registers-_0028nr_002c-_005cR_0029"></a>
+<a class="index-entry-id" id="index-registers_002c-setting-_0028nr_002c-_005cR_0029"></a>
+
+<p>Define registers and update their values with the <code class="code">nr</code> request or
+the <code class="code">\R</code> escape sequence.
+</p>
+<dl class="first-deffn">
+<dt class="deffn" id="index-_002enr-1"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.nr</code></strong> <var class="def-var-arguments">ident value</var><a class="copiable-link" href='#index-_002enr-1'> &para;</a></span></dt>
+<dd><a class="index-entry-id" id="index-nr-1"></a>
+</dd><dt class="deffnx def-cmd-deffn" id="index-_005cR_0027ident-value_0027"><span class="category-def">Escape&nbsp;sequence: </span><span><strong class="def-name"><code class="t">\R<code class="code">'</code></code><span class="r"><i class="slanted">ident value</i></span><code class="t"><code class="code">'</code></code></strong><a class="copiable-link" href='#index-_005cR_0027ident-value_0027'> &para;</a></span></dt>
+<dd><a class="index-entry-id" id="index-_005cR"></a>
+<p>Set register <var class="var">ident</var> to <var class="var">value</var>. If <var class="var">ident</var> doesn&rsquo;t exist,
+GNU <code class="code">troff</code> creates it. In the <code class="code">\R</code> escape sequence, the
+delimiter need not be a neutral apostrophe; see <a class="ref" href="Delimiters.html">Delimiters</a>. It
+also does not produce an input token in GNU <code class="code">troff</code>. See <a class="xref" href="Gtroff-Internals.html"><code class="code">gtroff</code> Internals</a>.
+</p>
+<div class="example">
+<div class="group"><pre class="example-preformatted">.nr a (((17 + (3 * 4))) % 4)
+\n[a]
+.\R'a (((17 + (3 * 4))) % 4)'
+\n[a]
+ &rArr; 1 1
+</pre></div></div>
+
+<p>(Later, we will discuss additional forms of <code class="code">nr</code> and <code class="code">\R</code> that
+can change a register&rsquo;s value after it is dereferenced but before it is
+interpolated. See <a class="xref" href="Auto_002dincrement.html">Auto-increment</a>.)
+</p>
+<p>The complete transparency of <code class="code">\R</code> can cause surprising effects if
+you use registers like <code class="code">.k</code>, which get evaluated at the time they
+are accessed.
+</p>
+<div class="example">
+<div class="group"><pre class="example-preformatted">.ll 1.6i
+.
+aaa bbb ccc ddd eee fff ggg hhh\R':k \n[.k]'
+.tm :k == \n[:k]
+ &rArr; :k == 126950
+.
+.br
+.
+aaa bbb ccc ddd eee fff ggg hhh\h'0'\R':k \n[.k]'
+.tm :k == \n[:k]
+ &rArr; :k == 15000
+</pre></div></div>
+
+<p>If you process this with the PostScript device (<code class="code">-Tps</code>), there will
+be a line break eventually after <code class="code">ggg</code> in both input lines.
+However, after processing the space after <code class="code">ggg</code>, the partially
+collected line is not overfull yet, so GNU <code class="code">troff</code> continues to
+collect input until it sees the space (or in this case, the newline)
+after <code class="code">hhh</code>. At this point, the line is longer than the line
+length, and the line gets broken.
+</p>
+<p>In the first input line, since the <code class="code">\R</code> escape sequence leaves no
+traces, the check for the overfull line hasn&rsquo;t been done yet at the
+point where <code class="code">\R</code> gets handled, and you get a value for the
+<code class="code">.k</code> register that is even greater than the current line length.
+</p>
+<p>In the second input line, the insertion of <code class="code">\h'0'</code> to cause a
+zero-width motion forces GNU <code class="code">troff</code> to check the line length,
+which in turn causes the start of a new output line. Now <code class="code">.k</code>
+returns the expected value.
+</p></dd></dl>
+
+<p><code class="code">nr</code> and <code class="code">\R</code> each have two additional special forms to
+increment or decrement a register.
+</p>
+<dl class="first-deffn">
+<dt class="deffn" id="index-_002enr-2"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.nr</code></strong> <var class="def-var-arguments">ident <code class="t">+</code><span class="r"><i class="slanted">value</i></span></var><a class="copiable-link" href='#index-_002enr-2'> &para;</a></span></dt>
+<dd><a class="index-entry-id" id="index-nr-2"></a>
+</dd><dt class="deffnx def-cmd-deffn" id="index-_002enr-3"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.nr</code></strong> <var class="def-var-arguments">ident <code class="t">-</code><span class="r"><i class="slanted">value</i></span></var><a class="copiable-link" href='#index-_002enr-3'> &para;</a></span></dt>
+<dt class="deffnx def-cmd-deffn" id="index-_005cR_0027ident-_002bvalue_0027"><span class="category-def">Escape&nbsp;sequence: </span><span><strong class="def-name"><code class="t">\R<code class="code">'</code></code><span class="r"><i class="slanted">ident <code class="t">+</code>value</i></span><code class="t"><code class="code">'</code></code></strong><a class="copiable-link" href='#index-_005cR_0027ident-_002bvalue_0027'> &para;</a></span></dt>
+<dd><a class="index-entry-id" id="index-_005cR-1"></a>
+</dd><dt class="deffnx def-cmd-deffn" id="index-_005cR_0027ident-_002dvalue_0027"><span class="category-def">Escape&nbsp;sequence: </span><span><strong class="def-name"><code class="t">\R<code class="code">'</code></code><span class="r"><i class="slanted">ident <code class="t">-</code>value</i></span><code class="t"><code class="code">'</code></code></strong><a class="copiable-link" href='#index-_005cR_0027ident-_002dvalue_0027'> &para;</a></span></dt>
+<dd><p>Increment (decrement) register <var class="var">ident</var> by <var class="var">value</var>. In the
+<code class="code">\R</code> escape sequence, the delimiter need not be a neutral
+apostrophe; see <a class="ref" href="Delimiters.html">Delimiters</a>.
+</p>
+<div class="example">
+<div class="group"><pre class="example-preformatted">.nr a 1
+.nr a +1
+\na
+ &rArr; 2
+</pre></div></div>
+
+<a class="index-entry-id" id="index-negating-register-values"></a>
+<p>A leading minus sign in <var class="var">value</var> is always interpreted as a
+decrementation operator, not an algebraic sign. To assign a register a
+negative value or the negated value of another register, you can
+force GNU <code class="code">troff</code> to interpret &lsquo;<samp class="samp">-</samp>&rsquo; as a negation or minus,
+rather than decrementation, operator: enclose it with its operand in
+parentheses or subtract it from zero.
+</p>
+<div class="example">
+<div class="group"><pre class="example-preformatted">.nr a 7
+.nr b 3
+.nr a -\nb
+\na
+ &rArr; 4
+.nr a (-\nb)
+\na
+ &rArr; -3
+.nr a 0-\nb
+\na
+ &rArr; -3
+</pre></div></div>
+
+<p>If a register&rsquo;s prior value does not exist (the register was undefined),
+an increment or decrement is applied as if to&nbsp;0.
+</p></dd></dl>
+
+<dl class="first-deffn">
+<dt class="deffn" id="index-_002err"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.rr</code></strong> <var class="def-var-arguments">ident</var><a class="copiable-link" href='#index-_002err'> &para;</a></span></dt>
+<dd><a class="index-entry-id" id="index-rr"></a>
+<a class="index-entry-id" id="index-removing-a-register-_0028rr_0029"></a>
+<a class="index-entry-id" id="index-register_002c-removing-_0028rr_0029"></a>
+<p>Remove register <var class="var">ident</var>. If <var class="var">ident</var> doesn&rsquo;t exist, the request
+is ignored. Technically, only the name is removed; the register&rsquo;s
+contents are still accessible under aliases created with <code class="code">aln</code>, if
+any.
+</p></dd></dl>
+
+<dl class="first-deffn">
+<dt class="deffn" id="index-_002ernn"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.rnn</code></strong> <var class="def-var-arguments">ident1 ident2</var><a class="copiable-link" href='#index-_002ernn'> &para;</a></span></dt>
+<dd><a class="index-entry-id" id="index-rnn"></a>
+<a class="index-entry-id" id="index-renaming-a-register-_0028rnn_0029"></a>
+<a class="index-entry-id" id="index-register_002c-renaming-_0028rnn_0029"></a>
+<p>Rename register <var class="var">ident1</var> to <var class="var">ident2</var>. If <var class="var">ident1</var> doesn&rsquo;t
+exist, the request is ignored. Renaming a built-in register does not
+otherwise alter its properties.
+</p></dd></dl>
+
+<dl class="first-deffn">
+<dt class="deffn" id="index-_002ealn"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.aln</code></strong> <var class="def-var-arguments">new old</var><a class="copiable-link" href='#index-_002ealn'> &para;</a></span></dt>
+<dd><a class="index-entry-id" id="index-aln"></a>
+<a class="index-entry-id" id="index-alias_002c-register_002c-creating-_0028aln_0029"></a>
+<a class="index-entry-id" id="index-creating-alias-for-register-_0028aln_0029"></a>
+<a class="index-entry-id" id="index-register_002c-creating-alias-for-_0028aln_0029"></a>
+<p>Create an alias <var class="var">new</var> for an existing register <var class="var">old</var>, causing
+the names to refer to the same stored object. If <var class="var">old</var> is
+undefined, a warning in category &lsquo;<samp class="samp">reg</samp>&rsquo; is produced and the request
+is ignored. See <a class="xref" href="Warnings.html">Warnings</a>, for information about the enablement and
+suppression of warnings.
+</p>
+<a class="index-entry-id" id="index-alias_002c-register_002c-removing-_0028rr_0029"></a>
+<a class="index-entry-id" id="index-removing-alias-for-register-_0028rr_0029"></a>
+<a class="index-entry-id" id="index-register_002c-removing-alias-for-_0028rr_0029"></a>
+<p>To remove a register alias, invoke <code class="code">rr</code> on its name. A register&rsquo;s
+contents do not become inaccessible until it has no more names.
+</p></dd></dl>
+
+
+</div>
+<hr>
+<div class="nav-panel">
+<p>
+Next: <a href="Interpolating-Registers.html">Interpolating Registers</a>, Previous: <a href="Registers.html">Registers</a>, Up: <a href="Registers.html">Registers</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Request-Index.html" title="Index" rel="index">Index</a>]</p>
+</div>
+
+
+
+</body>
+</html>