Dear Hans,

In addition to the small supp-mps.tex bugs reported in another mail,
there are some other macros missing from supp-mps.tex that are needed
to use supp-msp+ppchtex from plain TeX (without loading full ConTeXt).

Ppchtex.tex uses \pushMPdrawing and \popMPdrawing, defined in supp-mps.tex,
and making use themselves of \pushmacro and \popmacro, that are not yet
defined.

The problem can be solved copying from syst-ext.tex the definitions of
\pushmacro and \popmacro, plus the \increment and \decrement familly of
macros, plus \let\redoglobal\relax and \let\dodoglobal\relax.

I am using a file like the attached one to use ppchtex with metapost,
useful with both pdftex and tex+dvips. Perhaps that you may find useful
to add some of the missing macros to supp-mps.tex.

Regards,
Ricardo.

%%%%%%%%%%%%%%%%%% ppchmp.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% we need some conTeXt syst-ext.tex macros to avoid loading the full package
\catcode`\@=11

\let\redoglobal\relax
\let\dodoglobal\relax

%D \macros
%D   {newcounter,
%D    increment,decrement}
%D
%D Unfortunately the number of \COUNTERS\ in \TEX\ is limited,
%D but fortunately we can store numbers in a macro. We can
%D increment such pseudo \COUNTERS\ with \type{\increment}.
%D
%D \starttypen
%D \increment(\counter,20)
%D \increment(\counter,-4)
%D \increment(\counter)
%D \increment\counter
%D \stoptypen
%D
%D After this sequence of commands, the value of
%D \type{\counter} is 20, 16, 17 and~18. Of course there is
%D also the complementary command \type{\decrement}.
%D
%D Global assignments are possible too, using \type{\doglobal}:
%D
%D \starttypen
%D \doglobal\increment\counter
%D \stoptypen
%D
%D When \type{\counter} is undefined, it's value is initialized
%D at~0. It is nevertheless better to define a \COUNTER\
%D explicitly. One reason could be that the \COUNTER\ can be
%D part of a test with \type{\ifnum} and this conditional does
%D not accept undefined macro's. The \COUNTER\ in our example
%D can for instance be defined with:
%D
%D \starttypen
%D \newcounter\counter
%D \stoptypen
%D
%D The command \type{\newcounter} must not be confused with
%D \type{\newcount}! Of course this mechanism is much slower
%D than using \TEX's \COUNTERS\ directly. In practice
%D \COUNTERS\ (and therefore our pseudo counters too) are
%D seldom the bottleneck in the processing of a text. Apart
%D from some other incompatilities we want to mention a pitfal
%D when using \type{\ifnum}.
%D
%D \starttypen
%D \ifnum\normalcounter=\pseudocounter \doif \else \doelse \fi
%D \ifnum\pseudocounter=\normalcounter \doif \else \doelse \fi
%D \stoptypen
%D
%D In the first test, \TEX\ continues it's search for the
%D second number after reading  \type{\pseudocounter}, while
%D in the second test, it stops reading after having
%D encountered a real one. Tests like the first one therefore
%D can give unexpected results, for instance execution
%D of \type{\doif} even if both numbers are unequal.

\def\zerocountervalue{0}

\def\newcounter#1%
  {\dodoglobal\let#1\zerocountervalue}

\def\dodododoincrement(#1,#2)%
  {\ifx#1\undefined
     \redoglobal\let#1\zerocountervalue
   \else\ifx#1\relax % \csname...\endcsname
     \redoglobal\let#1\zerocountervalue
   \fi\fi
   \scratchcounter=#2\relax
   \scratchcounter=\incrementsign\scratchcounter
   \advance\scratchcounter #1\relax
   \dodoglobal\edef#1{\the\scratchcounter}}

\def\dododoincrement#1%
  {\dodododoincrement(#1,1)}

\def\dodoincrement(#1%
  {\doifnextcharelse{,}
     {\dodododoincrement(#1}
     {\dodododoincrement(#1,1}}

\def\doincrement#1%
  {\def\incrementsign{#1}%
   \doifnextcharelse{(}
     {\dodoincrement}
     {\dododoincrement}}

\def\increment%
  {\doincrement+}

\def\decrement%
  {\doincrement-}

%D \macros
%D   {pushmacro,popmacro}
%D
%D Premature and a bit of beta, we offer:
%D
%D \starttypen
%D \pushmacro\macro
%D \popmacro\macro
%D \stoptypen

\def\@s@{@s@}

\def\pushmacro#1% across groups !
  {\@EA\doglobal\@EA\increment\csname\@s@:\string#1\endcsname
   \global\@EA\let\csname\csname\@s@:\string#1\endcsname:\string#1\endcsname#1}

\def\popmacro#1%
  {\global\@EA\let\@EA#1\csname\csname\@s@:\string#1\endcsname:\string#1\endcsname
   \@EA\doglobal\@EA\decrement\csname\@s@:\string#1\endcsname}

\catcode`\@=12


% now, load context-metapost modules
\ifx\pdftexversion\undefined
%
% to insert the MP file using tex+dvips:
%
\input supp-eps
%
\def\insertMPfile#1%
  {\includeMPfonts{#1}%
   \dogetEPSboundingbox{#1}{\dimen2}{\dimen4}{\dimen6}{\dimen8}%
   \hbox to \dimen6{%
     \hskip-\EPSllx bp
     \vbox to \dimen8
       {\forgetall
        \vskip \EPSury bp
        \special{psfile=#1}%
        \vfill}%
     \hfill}}
%
% supp-mps.tex checks \pdfoutput, even if undefined!
\def\pdfoutput{0}
%
\else
%
% to insert the MP file using pdftex:
%
\input supp-pdf
%
\def\insertMPfile#1#2{\convertMPtoPDF{#1}{1}{1}}
%
\fi

\input supp-mps

% \startreusableMPgraphic needs this (yet) undefined macro:
\ifx\ifundefined\undefined
\message{*** define undefined macro (\string\ifundefined) ***}
\def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax}
\fi


% activate MP output (assuming we are using web2c-[pdf]tex -shell-escape)
\runMPgraphicstrue


% finally, we may load context-ppchtex modules
\input m-pictex
\input m-ch-en


\endinput
%%%%%%%%%%% end of ppchmp.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Reply via email to