core-two.mkxl /size: 5301 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=core-two, % moved from core-uti
3%D        version=1997.03.31, % stripped down 2023-03-21
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%D The public interface is replaced by datasets and two pass data is now private
15%D to the engine. For the moment we keep some commands commented. The unused
16%D (second) argument is an inheritance from \MKII. If needed we can bring back
17%D a compatible interface.
18
19\writestatus{loading}{ConTeXt Core Macros / Two Pass Data}
20
21\unprotect
22
23\registerctxluafile{core-two}{autosuffix}
24
25% %D This is a rather old mechanism which has not changed much over time, apart from
26% %D adding a few more selectors. This code used to be part of \type {core-uti}. The
27% %D following examples demonstrate the interface.
28% %D
29% %D \startbuffer
30% %D \definetwopasslist{test-1}
31% %D
32% %D \gettwopassdatalist{test-1} [\twopassdatalist=]
33% %D \checktwopassdata  {test-1} [\twopassdata=]
34% %D \checktwopassdata  {test-1} [\twopassdata=]
35% %D \gettwopassdata    {test-1} [\twopassdata=]
36% %D \gettwopassdata    {test-1} [\twopassdata=]
37% %D
38% %D \definetwopasslist{test-2}
39% %D
40% %D \lazysavetwopassdata{test-2}{1}{x}
41% %D \lazysavetwopassdata{test-2}{2}{y}
42% %D \lazysavetwopassdata{test-2}{3}{z}
43% %D
44% %D \gettwopassdatalist{test-2} [\twopassdatalist=x,y,z]
45% %D \checktwopassdata  {test-2} [\twopassdata=x]
46% %D \checktwopassdata  {test-2} [\twopassdata=x]
47% %D \gettwopassdata    {test-2} [\twopassdata=x]
48% %D \gettwopassdata    {test-2} [\twopassdata=y]
49% %D \gettwopassdata    {test-2} [\twopassdata=z]
50% %D \gettwopassdata    {test-2} [\twopassdata=]
51% %D
52% %D \definetwopasslist{test-3}
53% %D
54% %D \lazysavetaggedtwopassdata{test-3}{1}{x}{a}
55% %D \lazysavetaggedtwopassdata{test-3}{2}{y}{b}
56% %D \lazysavetaggedtwopassdata{test-3}{3}{z}{c}
57% %D
58% %D \findtwopassdata{test-3}{x} [\twopassdata=a]
59% %D \findtwopassdata{test-3}{y} [\twopassdata=b]
60% %D \findtwopassdata{test-3}{z} [\twopassdata=c]
61% %D \findtwopassdata{test-3}{w} [\twopassdata=]
62% %D
63% %D \definetwopasslist{test-4}
64% %D
65% %D \lazysavetwopassdata{test-4}{1}{A}
66% %D \lazysavetwopassdata{test-4}{2}{B}
67% %D \lazysavetwopassdata{test-4}{3}{C}
68% %D
69% %D \getfirsttwopassdata{test-4}    [\twopassdata=A]
70% %D \getlasttwopassdata {test-4}    [\twopassdata=C]
71% %D \getfirsttwopassdata{test-4}    [\twopassdata=A]
72% %D \getlasttwopassdata {test-4}    [\twopassdata=C]
73% %D \getfromtwopassdata {test-4}{1} [\twopassdata=A]
74% %D \getfromtwopassdata {test-4}{3} [\twopassdata=C]
75% %D \getfromtwopassdata {test-4}{2} [\twopassdata=B]
76% %D \stopbuffer
77% %D
78% %D \getbuffer \typebuffer
79%
80% %D The next code can be simplified (read: defined at the \LUA\ end) but we never use this
81% %D mechanism which has been replaced by datasets so it's not worth the effort.
82%
83% \permanent\def\immediatesavetwopassdata   #1#2#3{\normalexpanded{\noexpand\clf_savetwopassdata{#1}{#3}}}
84% \permanent\def     \lazysavetwopassdata   #1#2#3{\normalexpanded{\noexpand\ctxlatecommand{savetwopassdata("#1","#3")}}}
85% \permanent\let         \savetwopassdata          \lazysavetwopassdata
86% \permanent\def    \savetaggedtwopassdata#1#2#3#4{\normalexpanded{\noexpand\clf_savetaggedtwopassdata{#1}{#3}{#4}}}
87% \permanent\def\lazysavetaggedtwopassdata#1#2#3#4{\normalexpanded{\noexpand\ctxlatecommand{savetaggedtwopassdata("#1","#3","#4")}}}
88%
89% % temp hack: needs a proper \starteverytimeluacode
90%
91% \newconditional\twopassdatafound
92%
93% \mutable\lettonothing\twopassdata
94% \mutable\lettonothing\twopassdatalist
95%
96% \mutable\let\noftwopassitems\!!zeropoint
97%
98% \def\syst_twopass_check % can be delegated to lua once obsolete is gone
99%   {\ifempty\twopassdata
100%      \twopassdatafound\conditionalfalse
101%    \else
102%      \twopassdatafound\conditionaltrue
103%    \fi}
104%
105% \permanent\protected\def\definetwopasslist        #1{\clf_definetwopasslist{#1}}
106% \permanent\protected\def\gettwopassdata           #1{\edef\twopassdata    {\clf_gettwopassdata      {#1}}\syst_twopass_check}
107% \permanent\protected\def\checktwopassdata         #1{\edef\twopassdata    {\clf_checktwopassdata    {#1}}\syst_twopass_check}
108% \permanent\protected\def\findtwopassdata        #1#2{\edef\twopassdata    {\clf_findtwopassdata {#1}{#2}}\syst_twopass_check}
109% \permanent\protected\def\getfirsttwopassdata      #1{\edef\twopassdata    {\clf_getfirsttwopassdata {#1}}\syst_twopass_check}
110% \permanent\protected\def\getlasttwopassdata       #1{\edef\twopassdata    {\clf_getlasttwopassdata  {#1}}%
111%                                                      \edef\noftwopassitems{\clf_counttwopassdata    {#1}}\syst_twopass_check}
112% \permanent\protected\def\getnamedtwopassdatalist#1#2{\edef              #1{\clf_gettwopassdatalist  {#2}}}
113% \permanent\protected\def\gettwopassdatalist       #1{\edef\twopassdatalist{\clf_gettwopassdatalist  {#1}}}
114%
115% \permanent\protected\def\doifelseintwopassdata  #1#2{\clf_doifelseintwopassdata{#1}{#2}}
116%
117% \aliased\let\doifintwopassdataelse\doifelseintwopassdata
118% \aliased\let\getfromtwopassdata   \findtwopassdata
119
120\protect \endinput
121