This file is indexed.

/usr/share/doc/groff-base/html/pic-14.html is in groff 1.22.3-10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!-- Creator     : groff version 1.22.3 -->
<!-- CreationDate: Sat Feb 10 02:09:07 2018 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">
<style type="text/css">
       p       { margin-top: 0; margin-bottom: 0; vertical-align: top }
       pre     { margin-top: 0; margin-bottom: 0; vertical-align: top }
       table   { margin-top: 0; margin-bottom: 0; vertical-align: top }
       h1      { text-align: center }
</style>
<title>pic-14.html</title>

</head>
<hr>
[ <a href="pic-13.html">prev</a> | <a href="pic-15.html">next</a> | <a href="pic.html">top</a> ]
<hr>


<h2>14. Macros
<a name="14. Macros"></a>
</h2>


<p style="margin-top: 1em"><font color="#000000">You can
define macros in <b>pic</b>, with up to 32 arguments (up to
16 on EBCDIC platforms). This is useful for diagrams with
repetitive parts. In conjunction with the scope rules for
block composites, it effectively gives you the ability to
write functions.</font></p>

<p style="margin-top: 1em"><font color="#000000">The syntax
is</font></p>


<p style="margin-left:10%; margin-top: 1em"><font color="#000000"><b>define</b>
<i>name</i> <b>{</b> <i>replacement text</i>
<b>}</b></font></p>

<p style="margin-top: 1em"><font color="#000000">This
defines <i>name</i> as a macro to be replaced by the
replacement text (not including the braces). The macro may
be called as</font></p>


<p style="margin-left:10%; margin-top: 1em"><font color="#000000"><i>name</i><b>(</b><i>arg1,
arg2, ... argn</i><b>)</b></font></p>

<p style="margin-top: 1em"><font color="#000000">The
arguments (if any) are substituted for tokens <b>$1</b>,
<b>$2</b> ... <b>$n</b> appearing in the replacement
text.</font></p>

<p style="margin-top: 1em"><font color="#000000">As an
example of macro use, consider this:</font></p>
<pre style="margin-left:10%; margin-top: 1em">.PS
# Plot a single jumper in a box, $1 is the on-off state.
define jumper { [
    shrinkfactor = 0.8;
    Outer: box invis wid 0.45 ht 1;

    # Count on end ] to reset these
    boxwid = Outer.wid * shrinkfactor / 2;
    boxht  = Outer.ht  * shrinkfactor / 2;

    box fill (!$1) with .s at center of Outer;
    box fill ($1)  with .n at center of Outer;
] }

# Plot a block of six jumpers.
define jumperblock {
    jumper($1);
    jumper($2);
    jumper($3);
    jumper($4);
    jumper($5);
    jumper($6);

    jwidth  = last [].Outer.wid;
    jheight = last [].Outer.ht;

    box with .nw at 6th last [].nw wid 6*jwidth ht jheight;

    # Use {} to avoid changing position from last box draw.
    # This is necessary so move in any direction works as expected
    {&quot;Jumpers in state $1$2$3$4$5$6&quot; at last box .s + (0,-0.2);}
}


# Sample macro invocations.
jumperblock(1,1,0,0,1,0);
move;
jumperblock(1,0,1,0,1,1);
.PE</pre>


<p style="margin-top: 1em"><font color="#000000">It yields
the following:</font></p>


<p align="center" style="margin-top: 1em"><font color="#000000"><img src="img/pic44.png" alt="Image img/pic44.png"></font></p>


<p align="center" style="margin-top: 1em"><font color="#000000">Figure
14-1: Sample use of a macro</font></p>

<p style="margin-top: 1em"><font color="#000000">This macro
example illustrates how you can combine [], brace grouping,
and variable assignment to write true functions.</font></p>

<p style="margin-top: 1em"><font color="#000000">One detail
the example above does not illustrate is the fact that macro
argument parsing is not token-oriented. If you call
<b>jumper(&nbsp;1&nbsp;)</b>, the value of $1 is
<b>&quot;&nbsp;1&nbsp;&quot;</b>. You could even call
<b>jumper(big&nbsp;string)</b> to give $1 the value
<b>&quot;big&nbsp;string&quot;</b>.</font></p>

<p style="margin-top: 1em"><font color="#000000">If you
want to pass in a coordinate pair, you can avoid getting
tripped up by the comma by wrapping the pair in
parentheses.</font></p>

<p style="margin-top: 1em"><font color="#000000">Macros
persist through pictures. To undefine a macro, say
<b>undef</b> <i>name</i>; for example,</font></p>

<pre style="margin-left:10%; margin-top: 1em">undef jumper
undef jumperblock</pre>


<p style="margin-top: 1em"><font color="#000000">would
undefine the two macros in the jumper block
example.</font></p>
<hr>
[ <a href="pic-13.html">prev</a> | <a href="pic-15.html">next</a> | <a href="pic.html">top</a> ]
<hr>