%D \module
%D   [      file=x-e-1005,
%D        version=2003.01.26,
%D          title=\EXAMPLE\ GUI Files, 
%D       subtitle=Combining Files,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for 
%C details. 

%D This is experimental code. Don't change it, don't rely on
%D this interface remaining the same, don't use tricks used
%D here but not described in manuals, so: assume that this
%D file does not exists. 

\usemodule[e-0000] 

\loadEXArequest{\inputfilename}
\loadEXAmodes  {examodes.tex}

\setupoutput[pdftex]

\setuppapersize
  [\getEXAvariable{tex:var:paper:size},\getEXAvariable{tex:var:paper:orientation}]
  [\getEXAvariable{tex:var:paper:size},\getEXAvariable{tex:var:paper:orientation}]

\usetypescript[palatino][\defaultencoding]
\setupbodyfont[palatino]

\setuplayout
  [topspace=\getEXAvariable{tex:var:layout:offset},
   backspace=\getEXAvariable{tex:var:layout:offset},
   header=0pt,
   footer=\getEXAvariable{tex:var:footer:height},
   width=middle,
   height=middle]

\setupexternalfigures
  [directory=]

\startsetups[footer yes]

  \setupfootertexts[\getEXAvariable{tex:var:layout:file}\space---\space
    \currentdate\space---\space\pagenumber]

\stopsetups

\startsetups[footer no]

  \setuplayout[footer=no]

\stopsetups

\startsetups [footer text]

  \setupfootertexts[\getEXAvariable{tex:var:footer:text}]

\stopsetups

\startsetups[no file]

  \setuplayout[middle] \noheaderandfooterlines No file. 

\stopsetups

\def\CombinePages#1%
  {\setEXAvariable{tex:var:layout:file}{#1} % evt \lowercase{#1}
   \setups
     [footer \getEXAvariable{tex:var:footer:kind}]
   \combinepages
     [#1]
     [nx=\getEXAvariable{tex:var:combine:nx},
      ny=\getEXAvariable{tex:var:combine:ny}]}

\startsetups [a file]

  \processcommacommand[\theEXAfilelist]\CombinePages

\stopsetups

\starttext

\prepareEXAvariables

\doifelsenothing{\theEXAfilelist}
  {\setups[no file]}
  {\setups[a  file]}

\stoptext
