summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/plain/zztex/zzmerge.tex
blob: 05ef863971b6281018c83cec2e096c6bc49291d1 (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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Module:    ZzTeX Merge Print
%
% Synopsis:  This module provides a simple merge print facility for ZzTeX.
%
% Author:    Paul C. Anagnostopoulos
% Created:   17 October 2000
%
% Copyright 1989--2020 by Paul C. Anagnostopoulos
% under The MIT License (opensource.org/licenses/MIT)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%                       Merge Fields
%                       ----- ------


\setlist \zmrgfields = {}
\definecount{\zmrgcount}{0}

\def \mergefields #1{%
  \commalist{\zmrgfields}{#1}%
  \zmrgcount = 0
  \maplist{\increment \zmrgcount
           \withname\edef {\zmrgfmap:##1}{\the\zmrgcount}}
          {\zmrgfields}}

%                       Merge Text
%                       ----- ----


\definetoks{\zmrgtoks}

\long\def \mergetext #1\endmergetext{%
  \zmrgtoks = {#1}}

%                       Merge Print
%                       ----- -----


\definecount{\zmrgi}{0}


\def \mergeprint {%
  \zmrgi = 0
  \zmrgprinta}

\def \zmrgprinta #1{%
  \if \lssp{\zmrgi}{\zmrgcount}%
    \increment \zmrgi
    \withname\def {\zmrgvmap:\the\zmrgi}{#1}%
    \let \znext = \zmrgprinta
  \else
    \let \znext = \zmrgprintb
  \fi
  \znext}

\def \zmrgprintb {%
  \freshpage{\short\floats\any}%
  \the\zmrgtoks}

%                       Merge a Field
%                       ----- - -----


\def \merge #1{%
  \edef \tcounta {\name{\zmrgfmap:#1}}%
  \edef \znext {\name{\zmrgvmap:\the\tcounta}}%
  \znext}