diff options
Diffstat (limited to 'info/examples/tex-in-practice/counters.tip')
-rw-r--r-- | info/examples/tex-in-practice/counters.tip | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/info/examples/tex-in-practice/counters.tip b/info/examples/tex-in-practice/counters.tip new file mode 100644 index 0000000000..735e86d62e --- /dev/null +++ b/info/examples/tex-in-practice/counters.tip @@ -0,0 +1,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 |