blob: 735e86d62edc926321b3a1257a9a34840634000b (
plain)
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
|
% This macro source file is from the four volume series
% "TeX in Practice" by Stephan von Bechtolsheim, published
% 1993 by Springer-Verlag, New York.
% Copyright 1993 Stephan von Bechtolsheim.
% No warranty or liability is assumed.
% This macro may be copied freely if no fees other than
% media cost or shipping charges are charged and as long
% as this copyright and the following source code itself
% is not changed. Please see the series for further information.
%
% Version: 1.0
% Date: May 1, 1993
%
%
% This source code is documented in 3.4.2, p. I-71.
% Original source in file "reg1.TEX", starting line 2216.
\wlog{L: "counters.tip" ["reg1.TEX," l. 2216, p. I-71]}%
% This file DOES belong to format "texip."
\InputD{newoutfr.tip}
\InputD{printco.tip}
\InputD{namedef.tip}
\catcode`\@ = 11
\def\NewCounter #1#2#3#4{%
\wlog{\string\NewCounter: allocating new counter "#1."}%
\if\NameDefinedConditional{@C-#1}%
\errmessage{\string\NewCounter: counter "#1" was
allocated previously.}%
\fi
\expandafter\newcountOF\csname @C-#1\endcsname
\ReassignCounter{#1}{#2}{#3}{#4}%
\NameDef{@ResetC-#1}{}%
}
\def\ReassignCounter #1#2#3#4{%
\if\NameDefinedConditional{@C-#1}%
\else
\errmessage{\string\ReassignCounter: counter "#1"
not defined before.}%
\fi
\NameDef{@TheC-#1}{%
\expandafter\expandafter\expandafter#2%
\expandafter{\csname @C-#1\endcsname}%
}%
\NameDef{@TheArabicC-#1}{%
\expandafter\the\csname @C-#1\endcsname
}%
\NameDef{@PriC-#1}{#3}%
\NameDef{@RefC-#1}{#4}%
}
\def\TheCounter #1{%
\NameUse{@TheC-#1}%
}
\def\TheArabicCounter #1{%
\NameUse{@TheArabicC-#1}%
}
\def\PrintCounter #1{%
\NameUse{@PriC-#1}%
}
\def\RefCounter #1{%
\NameUse{@RefC-#1}%
}
\let\RefCounterTwo = \RefCounter
\def\CounterToRegister #1#2{%
#1 = \csname @C-#2\endcsname\relax
}
\def\AddCounterToResetList #1#2{%
{%
\def\@ResetCounter{\noexpand\@ResetCounter}%
\expandafter\xdef\csname @ResetC-#2\endcsname{%
\csname @ResetC-#2\endcsname\@ResetCounter{#1}%
}%
}%
}
\def\StepCounter #1{%
\global\expandafter\advance\csname @C-#1\endcsname by 1
\NameUse{@ResetC-#1}%
}
\def\SetCounter #1#2{%
\global\expandafter\csname @C-#1\endcsname = #2\relax
}
\def\AssignCounterToReg #1#2{%
#2 = \expandafter\csname @C-#1\endcsname
\relax
}
\def\@ResetCounter #1{%
\global\csname @C-#1\endcsname = 0
}
\catcode`\@ = 12
|