%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example of MCF   Typeset with LuaLaTeX(luamplib)   by A.Yamaji   2022.08.22
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ** mcf2graph.mf must be version 4.87
% ** use mcf_library.mcf
% ** typeset by LuaLaTeX(luamplib)
\documentclass{article}
\usepackage{luamplib}
\usepackage[T1]{fontenc}
\mplibcodeinherit{enable}
\mplibnumbersystem{double}
\mpliblegacybehavior{disabled}
%-------------------------------------------------------------------------
\everymplib{
  if unknown Ph1:
    input mcf2graph;
    outputformat:="eps";
    sw_output:=Fig+Calc;
    fsize:=(35mm,24mm);
    max_blength:=4mm;
  fi
}%
%-------------------------------------------------------------------------
\pagestyle{empty}
\topmargin=-24mm
\oddsidemargin=-12mm
\textwidth=192mm
\textheight=280mm
\parindent=0mm
\newcount\headeroff
\headeroff=0
\makeatletter
%-------------------------------------------------------------------------
\begin{document}
\ifnum\z@=\headeroff%
\begin{center}
 {\Huge\sf Molecular Coding Format examples} \vspace{5mm} \\
 Author : Akira Yamaji \quad Date : \today \\
 Located at : http://www.ctan.org/pkg/mcf2graph
\end{center}
{\small *typeset with LuaLaTeX \quad
        *use molecular library file 'mcf\_library.mcf' \\
        ** FM(fm):molecular formula (calculated) \quad 
        * MW(mw):molecular weight (calculated)} \vspace{3mm} \\
\fi%
%-------------------------------------------------------------------------
\noindent%
\newbox \fig@box%
\newcount \fig@num%
\newcount \col@num%
\font\labelM=cmtt8 at 6pt\relax%
%-------------------------------------------------------------------------
\fig@num=0%
\col@num=0%
\unitlength=0.01mm%
\edef\zero{0}%
\noindent%
%-------------------------------------------------------------------------
\newif\ifCONT@%
\CONT@true%
\loop%
\advance\fig@num\@ne\relax%
\advance\col@num\@ne\relax%
\sbox{\fig@box}{%
\begin{mplibcode}
  beginfigm("t:EXA","v+:1")
    if mc_check(mc)=0:
      MC(scantokens(mc))
      VerbatimTeX("\gdef\EN{"&inf_EN&"}");
      VerbatimTeX("\gdef\MW{"&inf_MW&"}");
      VerbatimTeX("\gdef\mw{"&cal_MW&"}");
      VerbatimTeX("\gdef\fm{"&cal_FM&"}");
   fi
  endfigm
  VerbatimTeX("\gdef\EOF{"&decimal(f_EOF)&"}");
\end{mplibcode}
}%
%------------------------------------------------------------------------
\ifx\EOF\zero%
  \begin{picture}(3750,3350)%
    \put(20,3000){\footnotesize\bf \EN}%
    \put(20,2750){\labelM mw:\mw { / }fm:\fm}%
    \put(20,2530){\labelM MW:\MW { / }[\the\fig@num]}%
    \put(0,0){\makebox(3750,2530){\usebox{\fig@box}}}%
  \end{picture}%
  \ifnum\col@num=5 \\ \col@num=\z@ \fi%
\else%
  \CONT@false%
\fi%
%------------------------------------------------------------------------
%%%%%%%%\ifnum\fig@num=10 \CONT@false \fi%
\message{[\the\fig@num:\EN]}%
\ifCONT@ \repeat%
%------------------------------------------------------------------------------
\end{document}
