diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/arrayjob/arrayjob.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/arrayjob/arrayjob.sty | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/arrayjob/arrayjob.sty b/Master/texmf-dist/tex/generic/arrayjob/arrayjob.sty new file mode 100644 index 00000000000..0712a49d114 --- /dev/null +++ b/Master/texmf-dist/tex/generic/arrayjob/arrayjob.sty @@ -0,0 +1,188 @@ +% ARRAY STRUCTURE - arrayjob.sty - Version 1.03 - 05/03/00 +% +% By Zhuhan Jiang (01/05/95), extracted from formlett.sty +% (see CTAN/macros/generic/formlett.sty from line 344 to line 483) +% +% This program can be redistributed and/or modified under the terms +% of the LaTeX Project Public License distributed from CTAN archives +% in directory macros/latex/base/lppl.txt +% +% * 01/05/95 - Version 1.00 +% + Original version +% * 12/21/99 - Version 1.01 +% + Spurious blanks removed in \read@array and \get@max@count +% (reported by Antonio Leitao <aml@gia.ist.utl.pt> +% and Denis Girou <Denis.Girou@idris.fr>) +% * 04/05/00 - Version 1.02 +% + Add the \ifexpandarrayelement macro to allow to evaluate +% or not the content to put as an element of the array +% (from Denis Girou <Denis.Girou@idris.fr>) +% + Put this package under the terms of the LaTeX Project +% Public License +% * 05/03/00 - Version 1.03 +% + Add a \ProvidesPackage macro when LaTeX is used +% (according to the example given by Bernd Raichle +% <raichle@Informatik.Uni-Stuttgart.DE>) +% +% +% \newarray\ARRAYNAME +% \delarray\ARRAYNAME +% +% \ARRAYNAME(A1,..,An)={T} +% \readarray{ARRAYNAME}{ B1 & B2 & ... & Bm } +% \dataheight +% +% \data(A1,...,An)=\data( A1 + (A2-1)*\dataheight + +% ... + (An-1)*\dataheight^{n-1} ) +% if \normalindextrue +% =\data( An + (An-1 -1)*\dataheight + +% ... + (A1-1)*\dataheight^{n-1} ) +% if \normalindexfalse +% +% \checkARRAYNAME(A1,..,An) +% \ifemptydata valid when \checkARRAYNAME is just executed +% \cachedata: keeps the data of \ARRAYNAME(m) +% when \checkARRAYNAME(m) is executed +% +% OTHERS: +% save to array: \array{n}(m)={T} +% get from array: \array{n}(m) +% clear element: \clrarray{n}(m) +% test element: \testarray{n}(m) +% macro save to \temp@macro +% +% +% e.g. +% +% \newarray\Table +% \readarray{Table}{one&two& \unknownmacro && &six} +% \Table(7)={seven} +% \dataheight=0 % or 1 or < 0 +% \Table(7) = \Table(2,6,1) % 7=1+(2-1)+(6-1)+(1-1) +% \normalindexfalse +% \dataheight=3 +% \Table(7) = \Table(1,7) = \Table(3,1) +% \normalindextrue +% \Table(7) = \Table(7,1) = \Table(1,3) +% +% \checkTable(4) \ifemptydata (4)=empty \fi +% \checkTable(5) \ifemptydata\else (5)=nonempty \fi +% \ifx\cachedata\space ={\tt <space>}\fi +% \checkTable(1000) \ifemptydata (1000)=empty \fi +% +% \delarray\Table +% +% +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname ProvidesPackage\endcsname\relax% +\else + \ProvidesPackage{arrayjob}[2000/05/03 v1.03 Array management] +\fi +% +\xdef\EntryArrayJob{\the\catcode`\@}\catcode`\@=11\relax +\newif\ifemptydata \newcount\dataheight +\newif\ifnormalindex \normalindexfalse +% +\newcount\array@width \newcount\index@count \newcount\index@total +\newif\ifone@VEC \newif\if@rev@index +\newtoks\temp@toks \newcount\temp@count +\newcount\temp@@count \newcount\temp@@@count +% +\newif\ifexpandarrayelement +% +\long\def\assign@VEC#1(#2)=#3{\temp@count=#2 \relax +\get@max@count{total@#1}\temp@count +\ifexpandarrayelement + \expandafter\xdef\csname#1#2\string~\endcsname{#3}% +\else + \expandafter\gdef\csname#1#2\string~\endcsname{#3}% +\fi} +\def\get@VEC#1(#2){\csname#1#2\string~\endcsname} +\def\clrarray#1(#2){% + \global\expandafter\let\csname#1#2\string~\endcsname=\undefined@} +% +\def\testarray#1(#2){% + \expandafter\let\expandafter\temp@macro\csname#1#2\string~\endcsname + \ifx\temp@macro\relax \def\temp@macro{}\fi}% +% +\def\array#1(#2){\def\check@VEC{% + \ifx=\next@VEC \def\full@VEC####1{\assign@VEC#1(#2)####1}% + \else \def\full@VEC{\get@VEC#1(#2)}\fi \full@VEC}%check@VEC +\futurelet\next@VEC\check@VEC} +% +\def\get@index(#1)#2\safty@mark{\one@VEC#2,\safty@mark + \def\next@@VEC{#1}\ifx\next@@VEC\empty\def\next@@VEC{\array@width}\fi + \if@rev@index + {\temp@count=1 \advance\index@count1 \relax + \ifnum\index@count<\index@total + \loop \multiply\temp@count \next@@VEC + \advance\index@count-1 \relax + \ifnum\index@count>0 \repeat + \fi \global\temp@@count\temp@count }% + \else \multiply\temp@@count \next@@VEC \fi + \ifnum\temp@@count=0 \temp@@count=1 \relax \fi + \advance\temp@count-1 \ifnum\temp@count<0 \temp@count=0 \fi + \multiply\temp@count \temp@@count + \advance\temp@@@count by \temp@count \advance\index@count1 + \ifone@VEC + \def\next@@VEC{\index@total=\index@count \advance\temp@@@count1 }% + \else \one@VEC#2\safty@mark \edef\next@@VEC{\noexpand\get@index(#1)% + \the\temp@toks\noexpand\safty@mark}% + \fi \next@@VEC}% +% +\def\one@VEC#1,#2\safty@mark{\def\temp@macro{#2}\temp@toks={#2}% + \ifx\temp@macro\empty \one@VECtrue \else \one@VECfalse \fi + \temp@count=#1 \relax }% +% +\def\get@all@index(#1)#2\safty@mark{% + \temp@@@count=0 \temp@@count=0 \index@count=0 \@rev@indexfalse + \get@index(#1)#2\safty@mark + \ifnormalindex\else + \temp@@@count=0 \temp@@count=0 \index@count=0 \@rev@indextrue + \get@index(#1)#2\safty@mark \fi }% +% +\def\read@array[#1]#2#3{\temp@count=1 + \def\one@item##1#1##2\safty@mark{\def\temp@macro{##2}\temp@toks={##2}% + \ifx\temp@macro\empty\else + \def\temp@macro{\one@item##2\safty@mark}\fi + {\temp@toks={##1}\def\temp@@macro{\array{#2}(\the\temp@count)=}% + \expandafter\temp@@macro\expandafter{\the\temp@toks}}% + \expandafter\edef\csname total@#2\endcsname{\the\temp@count}% + \advance\temp@count1\temp@macro}% + \one@item#3#1\safty@mark}% +% +\def\strip@esc#1{\temp@count=\escapechar \escapechar=-1 % + \temp@toks=\expandafter{\string#1}\escapechar\temp@count} +\def\get@max@count#1#2{\edef\temp@macro{\csname #1\endcsname}% + \ifnum\temp@macro<#2\expandafter\xdef\csname #1\endcsname{\the#2}\fi}% +% +\def\newarray#1{\strip@esc{#1}% + \expandafter\gdef\csname total@\the\temp@toks\endcsname{0}% + \expandafter\edef\csname\the\temp@toks\endcsname(##1)% + {\noexpand\get@all@index(\noexpand\dataheight)##1\noexpand\safty@mark +% \noexpand\get@max@count{total@\the\temp@toks}\noexpand\temp@@@count + \noexpand\array{\the\temp@toks}(\noexpand\the\noexpand\temp@@@count)}% + \expandafter\edef\csname check\the\temp@toks\endcsname(##1)% + {\noexpand\get@all@index(\noexpand\dataheight)##1\noexpand\safty@mark + \noexpand\testarray{\the\temp@toks}(\noexpand\the + \noexpand\temp@@@count)\noexpand\let\noexpand\cachedata + \noexpand\temp@macro\noexpand\ifx\noexpand\temp@macro\noexpand\empty + \noexpand\emptydatatrue\noexpand\else\noexpand\emptydatafalse + \noexpand\fi}}% +% +\def\delarray#1{\strip@esc{#1}% delete array globally + \temp@count=0 \temp@@count=\csname total@\the\temp@toks\endcsname + \loop \expandafter\global\expandafter\let + \csname\the\temp@toks\string~\endcsname\undefined@ + \advance\temp@count1 % + \ifnum\temp@count<\temp@@count \repeat % global loop for less memory + \global\expandafter\let\csname total@\the\temp@toks\endcsname\undefined@ + \global\expandafter\let\csname \the\temp@toks\endcsname\undefined@ + \global\expandafter\let\csname check\the\temp@toks\endcsname\undefined@ }% +% +\def\readarray#1#2{\read@array[&]{#1}{#2}}% +% +\catcode`\@=\EntryArrayJob\relax +\endinput +% +% END OF MACROS |