core-two.mkiv /size: 4792 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=core-two, % moved from core-uti
3
%D version=1997.03.31,
4
%D title=\CONTEXT\ Core Macros,
5
%D subtitle=Two Pass Data,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\writestatus
{
loading
}
{
ConTeXt
Core
Macros
/
Two
Pass
Data
}
15 16
%D This is a rather old mechanism which has not changed much over
17
%D time, apart from adding a few more selectors. This code used
18
%D to be part of \type {core-uti}. The following examples demonstrate
19
%D the interface.
20
%D
21
%D \startbuffer
22
%D \definetwopasslist{test-1}
23
%D
24
%D \gettwopassdatalist{test-1} [\twopassdatalist=]
25
%D \checktwopassdata {test-1} [\twopassdata=]
26
%D \checktwopassdata {test-1} [\twopassdata=]
27
%D \gettwopassdata {test-1} [\twopassdata=]
28
%D \gettwopassdata {test-1} [\twopassdata=]
29
%D
30
%D \definetwopasslist{test-2}
31
%D
32
%D \lazysavetwopassdata{test-2}{1}{x}
33
%D \lazysavetwopassdata{test-2}{2}{y}
34
%D \lazysavetwopassdata{test-2}{3}{z}
35
%D
36
%D \gettwopassdatalist{test-2} [\twopassdatalist=x,y,z]
37
%D \checktwopassdata {test-2} [\twopassdata=x]
38
%D \checktwopassdata {test-2} [\twopassdata=x]
39
%D \gettwopassdata {test-2} [\twopassdata=x]
40
%D \gettwopassdata {test-2} [\twopassdata=y]
41
%D \gettwopassdata {test-2} [\twopassdata=z]
42
%D \gettwopassdata {test-2} [\twopassdata=]
43
%D
44
%D \definetwopasslist{test-3}
45
%D
46
%D \lazysavetaggedtwopassdata{test-3}{1}{x}{a}
47
%D \lazysavetaggedtwopassdata{test-3}{2}{y}{b}
48
%D \lazysavetaggedtwopassdata{test-3}{3}{z}{c}
49
%D
50
%D \findtwopassdata{test-3}{x} [\twopassdata=a]
51
%D \findtwopassdata{test-3}{y} [\twopassdata=b]
52
%D \findtwopassdata{test-3}{z} [\twopassdata=c]
53
%D \findtwopassdata{test-3}{w} [\twopassdata=]
54
%D
55
%D \definetwopasslist{test-4}
56
%D
57
%D \lazysavetwopassdata{test-4}{1}{A}
58
%D \lazysavetwopassdata{test-4}{2}{B}
59
%D \lazysavetwopassdata{test-4}{3}{C}
60
%D
61
%D \getfirsttwopassdata{test-4} [\twopassdata=A]
62
%D \getlasttwopassdata {test-4} [\twopassdata=C]
63
%D \getfirsttwopassdata{test-4} [\twopassdata=A]
64
%D \getlasttwopassdata {test-4} [\twopassdata=C]
65
%D \getfromtwopassdata {test-4}{1} [\twopassdata=A]
66
%D \getfromtwopassdata {test-4}{3} [\twopassdata=C]
67
%D \getfromtwopassdata {test-4}{2} [\twopassdata=B]
68
%D \stopbuffer
69
%D
70
%D \getbuffer \typebuffer
71 72
\unprotect
73 74
\registerctxluafile
{
core
-
two
}
{
}
75 76
\def
\immediatesavetwopassdata
#
1
#
2
#
3
{
\normalexpanded
{
\noexpand
\clf_savetwopassdata
{
#
1
}
{
#
3
}
}
}
77
\def
\lazysavetwopassdata
#
1
#
2
#
3
{
\normalexpanded
{
\noexpand
\ctxlatecommand{
savetwopassdata
(
"
#1
"
,
"
#3
"
)
}
}
}
78
\let
\savetwopassdata
\lazysavetwopassdata
79
\def
\savetaggedtwopassdata
#
1
#
2
#
3
#
4
{
\normalexpanded
{
\noexpand
\clf_savetaggedtwopassdata
{
#
1
}
{
#
3
}
{
#
4
}
}
}
80
\def
\lazysavetaggedtwopassdata
#
1
#
2
#
3
#
4
{
\normalexpanded
{
\noexpand
\ctxlatecommand{
savetaggedtwopassdata
(
"
#1
"
,
'
#3
'
,
"
#4
"
)
}
}
}
81 82
% temp hack: needs a proper \starteverytimeluacode
83 84
\setfalse
\twopassdatafound
85
\let
\twopassdata
\empty
86
\let
\twopassdatalist
\empty
87 88
\newif
\iftwopassdatafound
% obsolete, will go
89 90
\def
\syst_twopass_check
% can be delegated to lua once obsolete is gone
91
{
\ifx
\twopassdata
\empty
92
\twopassdatafoundfalse
% obsolete
93
\setfalse
\twopassdatafound
94
\else
95
\twopassdatafoundtrue
% obsolete
96
\settrue
\twopassdatafound
97
\fi
}
98 99
\def
\syst_twopass_set_not_found
100
{
\twopassdatafoundfalse
% obsolete
101
\setfalse
\twopassdatafound
}
102 103
\def
\syst_twopass_set_found
104
{
\twopassdatafoundtrue
% obsolete
105
\settrue
\twopassdatafound
}
106 107
\unexpanded
\def
\definetwopasslist
#
1
{
\clf_definetwopasslist
{
#
1
}
}
108
\unexpanded
\def
\gettwopassdata
#
1
{
\edef
\twopassdata
{
\clf_gettwopassdata
{
#
1
}
}
\syst_twopass_check
}
109
\unexpanded
\def
\checktwopassdata
#
1
{
\edef
\twopassdata
{
\clf_checktwopassdata
{
#
1
}
}
\syst_twopass_check
}
110
\unexpanded
\def
\findtwopassdata
#
1
#
2
{
\edef
\twopassdata
{
\clf_findtwopassdata
{
#
1
}
{
#
2
}
}
\syst_twopass_check
}
111
\unexpanded
\def
\getfirsttwopassdata
#
1
{
\edef
\twopassdata
{
\clf_getfirsttwopassdata
{
#
1
}
}
\syst_twopass_check
}
112
\unexpanded
\def
\getlasttwopassdata
#
1
{
\edef
\twopassdata
{
\clf_getlasttwopassdata
{
#
1
}
}
%
113
\edef
\noftwopassitems
{
\clf_counttwopassdata
{
#
1
}
}
\syst_twopass_check
}
114
\unexpanded
\def
\getnamedtwopassdatalist
#
1
#
2
{
\edef
#
1
{
\clf_gettwopassdatalist
{
#
2
}
}
}
115
\unexpanded
\def
\gettwopassdatalist
#
1
{
\edef
\twopassdatalist
{
\clf_gettwopassdatalist
{
#
1
}
}
}
116 117
\unexpanded
\def
\doifelseintwopassdata
#
1
#
2
{
\clf_doifelseintwopassdata
{
#
1
}
{
#
2
}
}
118 119
\let
\doifintwopassdataelse
\doifelseintwopassdata
120
\let
\getfromtwopassdata
\findtwopassdata
121 122
\protect
\endinput
123