[NTG-context] Register with numeric values

luigi scarso luigi.scarso at gmail.com
Wed Apr 26 17:47:12 CEST 2006


I make an example here:
%% BEGIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setupinteraction[state=start]
\setupcolors[state=start]
\definecolor[BackBrand][black]
\definecolor[Brand][white]

\newcount\ICfdigit
\newif\ifDoZero   \DoZerotrue
\newif\ifDoOne	  \DoOnetrue
\newif\ifDoTwo	  \DoTwotrue
\newif\ifDoThree  \DoThreetrue
\newif\ifDoFour	  \DoFourtrue
\newif\ifDoFive	  \DoFivetrue
\newif\ifDoSix	  \DoSixtrue
\newif\ifDoSeven  \DoSeventrue
\newif\ifDoEight \DoEighttrue
\newif\ifDoNine   \DoNinetrue
\newif\ifDoOtherDig   \DoOtherDigtrue

\defineregister[IndexCode][IndexCodes]
\def\ICTextCommand#1{%
\getfirstcharacter{#1}\ICfdigit=\firstcharacter%
\ifcase\firstcharacter %%\ICfdigit %% 0
\ifDoZero\global\DoZerofalse\ICHeadLetterCommand{0}\fi
\or%% 1
\ifDoOne\global\DoOnefalse\ICHeadLetterCommand{1}\fi
\or%% 2
\ifDoTwo\global\DoTwofalse\ICHeadLetterCommand{2}\fi
\or%% 3
\ifDoThree\global\DoThreefalse\ICHeadLetterCommand{3}\fi
\or%% 4
\ifDoFour\global\DoFourfalse\ICHeadLetterCommand{4}\fi
\or%% 5
\ifDoFive\global\DoFivefalse\ICHeadLetterCommand{5}\fi
\or%% 6
\ifDoSix\global\DoSixfalse\ICHeadLetterCommand{6}\fi
\or%% 7
\ifDoSeven\global\DoSevenfalse\ICHeadLetterCommand{7}\fi
\or%% 8
\ifDoEight\global\DoEightfalse\ICHeadLetterCommand{8}\fi
\or%% 9
\ifDoNine\global\DoNinefalse\ICHeadLetterCommand{9}\fi
\else
\ifDoOtherDig\global\DoOtherDigfalse\ICHeadLetterCommandSym{$\bigstar$}{*}\fi
\fi%
\hskip1sp#1%
}%%
\def\ICPageCommand#1{\relax}
%
\def\ICHeadLetterCommand#1{%
\blank
\framed[strut=no,width=2em,height=2em,background=color,backgroundcolor=BackBrand,foregroundcolor=Brand]{\bfb
#1\pagereference[IndexCode:NR#1]}\par\nobreak}
%
\def\ICHeadLetterCommandSym#1#2{%
\blank
\framed[strut=no,width=2em,height=2em,background=color,backgroundcolor=BackBrand,foregroundcolor=Brand]{\bfb
#1\pagereference[IndexCode:NR#2]}\par\nobreak}
\def\ICHeadLetterOtherCommand#1{\relax}
%%%%%
\setupregister[IndexCode][n=2,
                         align=yes,
			 balance=no,
                         symbol=1,
                         %distance=0pt,
                         %expand=no,
                         %distance=0bp,
			 %partnumber=no,
			 %indicator=yes,
			 %% interaction=text,
                         textstyle={\tfa},
			 textcommand={\ICTextCommand},
			 %% pagecommand={\ICPageCommand},
			 command={\ICHeadLetterOtherCommand},%
                         ]

\def\ICLetterEntry#1{%
\bTD
\doifreferencepermittedelse{IndexCode:NR#1}{%
\goto{\framed[strut=no,width=2em,height=2em,background=color,backgroundcolor=BackBrand,foregroundcolor=Brand]{\bfb
#1}}[IndexCode:NR#1]}
{\framed[strut=no,width=2em,height=2em,background=color,backgroundcolor=BackBrand,foregroundcolor=Brand]{\bfb}}
\eTD%
}

\def\ICLetterEntrySymbol#1#2{%
\bTD
\doifreferencepermittedelse{IndexCode:NR#2}{%
\goto{\framed[strut=no,width=2em,height=2em,background=color,backgroundcolor=BackBrand,foregroundcolor=Brand]{\bfb
#1}}[IndexCode:NR#2]}
{\framed[strut=no,width=2em,height=2em,background=color,backgroundcolor=BackBrand,foregroundcolor=Brand]{}}
\eTD%
}

\def\PutICLetterEntry{%
\setupTABLE[frame=off]
\bTABLE
\bTR
\ICLetterEntry{0}\ICLetterEntry{1}\ICLetterEntry{2}\ICLetterEntry{3}%
\ICLetterEntry{4}\ICLetterEntry{5}\ICLetterEntry{6}\ICLetterEntry{7}
\eTR
\bTR
\ICLetterEntry{8}\ICLetterEntry{9}\ICLetterEntrySymbol{$\bigstar$}{*}%
\eTR\eTABLE
}


\starttext
\IndexCode{00328273}    {00328273}            \par
\IndexCode{12328273}    {12328273}            \par
\IndexCode{2328273}	{2328273}             \par
\IndexCode{3328273}	{3328273}             \par
\IndexCode{3334328273}	{3334328273}          \par
\IndexCode{4}		{4}                   \par
\IndexCode{5553}	{5553}                \par
\IndexCode{644328273}	{644328273}           \page
\IndexCode{844328273}	{844328273}           \par
\IndexCode{944328273}	{944328273}           \par
\IndexCode{944328273}	{944328273}           \par
\IndexCode{944328273}	{944328273}           \par

\page
{\tfd TEST }\par
\PutICLetterEntry\par
\page
\placeIndexCode

\stoptext
%% END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> you can file a feature request to treat numbers 'as characters'
>
> Hans
Sorry, I don't understand that.


More information about the ntg-context mailing list