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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
%D \module
%D [ file=core-dat,
%D version=20122.04.17, % replaces core-two from 1997.03.31,
%D title=\CONTEXT\ Core Macros,
%D subtitle=Multipass Datasets,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{ConTeXt Core Macros / Multipass Datasets}
%D \starttyping
%D \definedataset[test-1]
%D \definedataset[test-2][delay=yes]
%D
%D \startlines
%D set 1: \setdataset[test-1][whatever=this-or-that-1]
%D set 2: \setdataset[test-2][whatever=this-or-that-2]
%D set 3: \setdataset[test-2][whatever=this-or-that-3]
%D \stoplines
%D
%D \startlines
%D get 1: \datasetvariable{test-1}{1}{whatever} / \datasetvariable{test-1}{1}{realpage}
%D get 2: \datasetvariable{test-2}{1}{whatever} / \datasetvariable{test-2}{1}{realpage}
%D get 3: \datasetvariable{test-2}{2}{whatever} / \datasetvariable{test-2}{2}{realpage}
%D \stoplines
%D \stoptyping
\unprotect
\registerctxluafile{core-dat}{1.001}
\installcorenamespace{dataset}
\installcommandhandler \??dataset {dataset} \??dataset
\unexpanded\def\setdataset
{\dotripleempty\syst_datasets_set}
\def\syst_datasets_set
{\ifthirdargument
\expandafter\syst_datasets_set_named
\else
\expandafter\syst_datasets_set_indexed
\fi}
\def\syst_datasets_set_named[#1][#2][#3]%
{\begingroup
\edef\currentdataset{#1}%
\ctxcommand{setdataset{
name = "\currentdataset",
tag = \!!bs#2\!!es,
delay = "\datasetparameter\c!delay",
data = \!!bs#3\!!es
}}%
\endgroup}
\def\syst_datasets_set_indexed[#1][#2][#3]%
{\begingroup
\edef\currentdataset{#1}%
\ctxcommand{setdataset{
name = "\currentdataset",
delay = "\datasetparameter\c!delay",
data = \!!bs#2\!!es
}}%
\endgroup}
\def\datasetvariable#1#2#3%
{\ctxcommand{datasetvariable("#1","#2","#3")}}
\installcorenamespace{pagestate}
\installcommandhandler \??pagestate {pagestate} \??pagestate
\setuppagestate
[\c!delay=\v!yes]
\unexpanded\def\setpagestate
{\dodoubleempty\syst_pagestates_set}
\def\syst_pagestates_set[#1][#2]%
{\begingroup
\edef\currentpagestate{#1}%
\ctxcommand{setpagestate{
name = "\currentpagestate",
tag = \!!bs#2\!!es,
delay = "\pagestateparameter\c!delay",
}}%
\endgroup}
\def\pagestaterealpage#1#2%
{\ctxcommand{pagestaterealpage("#1","#2")}}
\def\setpagestaterealpageno#1#2%
{\ctxcommand{setpagestaterealpageno("#1","#2")}}
\protect
|