home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / tex / macros / source / contrib / custom-bib / makebst.tex < prev    next >
Encoding:
Text File  |  1995-03-10  |  7.0 KB  |  213 lines

  1. %% 
  2. %% This is file `makebst.tex', generated 
  3. %% on <1995/3/4> with the docstrip utility (2.2i).
  4. %% 
  5. %% The original source files were:
  6. %% 
  7. %% makebst.dtx  (with options: `program,optlist')
  8. %% 
  9. %% This is the `program' part of the source file. 
  10. %% It may be run either with TeX or LaTeX. 
  11. %% 
  12. \def\ProvidesFile#1 [#2 #3 #4]{\def\filename{#1}%
  13.   \def\fileversion{#3}\def\filedate{#2}}
  14.  \ProvidesFile{makebst}
  15.     [1995/01/02 2.1 (PWD)]
  16.  %-------------------------------------------------------------------
  17.  % NOTICE:
  18.  % This file may be used for non-profit purposes.
  19.  % It may not be distributed in exchange for money,
  20.  %   other than distribution costs.
  21.  %
  22.  % The author provides it `as is' and does not guarantee it in any way.
  23.  %
  24. %% Copyright (C) 1994, 1995 Patrick W. Daly
  25.  % Max-Planck-Institut f\"ur Aeronomie
  26.  % Postfach 20
  27.  % D-37189 Katlenburg-Lindau
  28.  % Germany
  29.  %
  30.  % E-mail:
  31.  % SPAN--     nsp::linmpi::daly    (note nsp also known as ecd1)
  32.  % Internet-- daly@linax1.dnet.gwdg.de
  33.  %-----------------------------------------------------------
  34.  % This file is to be run under TeX (or even LaTeX)
  35.  % It interactively asks questions about the bibliographic style file
  36.  % that you want to produce. When it is finished, it writes a docstrip
  37.  % driver file that produces that .bst file from the generic .mbs that
  38.  % you specified; optionally, it will call the docstrip run immediately.
  39.  % For details, read the documentation in the source file makebst.dtx.
  40.  %--------------------------------------------------------------------
  41. \newwrite\outfile
  42. \newread\infile
  43. \newread\ttyin
  44. \newwrite\ttyout
  45. \def\mes{\immediate\write\ttyout}
  46. \def\wr#1{\immediate\write\outfile{#1}}
  47. \newlinechar=`\^^J
  48. \def\defpar{\par}
  49. \def\remblk#1 @@{#1}
  50. \def\ask#1#2{\mes{#2}\read\ttyin to #1\ifx#1\defpar\def#1{}\else
  51.    \edef#1{\expandafter\remblk#1@@}\fi}
  52. \def\groot#1.#2@@{#1}
  53. \def\getroot#1{\expandafter\groot#1.@@}
  54. \def\gext#1.#2.#3@@{#2}
  55. \def\getext#1{\expandafter\gext#1..@@}
  56. {\catcode`\%=12
  57.  \gdef\pc{%}
  58.  \gdef\pcpc{%% }
  59. }
  60. \def\spsp{\space\space}
  61. \newcount\hours
  62. \newcount\minutes
  63. \def\SetTime{\hours=\time
  64.         \global\divide\hours by 60
  65.         \minutes=\hours
  66.         \multiply\minutes by 60
  67.         \advance\minutes by-\time
  68.         \global\multiply\minutes by-1 }
  69. \SetTime
  70. \def\now{\number\hours:\ifnum\minutes<10 0\fi\number\minutes}
  71. \def\today{\number\year/\ifnum\month<10 0\fi\number\month
  72.    /\ifnum\day<10 0\fi\number\day}
  73. \def\Now{\today\space at \now}
  74. \def\optdef#1#2#3#4{\expandafter\def\csname opt@#1\endcsname{#2}%
  75.   \expandafter\def\csname txt@#1\endcsname{#3}%
  76.   \edef\optlist{#1,\optlist}%
  77.   \mes{(#1) #3\space #4}}
  78.  
  79. \def\optlist{?,}
  80.  
  81. \def\nxtopt#1,#2@@{#1} \def\rstopt#1,#2@@{#2}
  82.  
  83. \newif\ifsw
  84. \def\getans{\ask{\ans}{\spsp Select:}
  85.   \expandafter\ifx\csname opt@\ans\endcsname\relax \def\ans{*}\fi
  86.   \expandafter\ifx\csname opt@\ans\endcsname\relax
  87.      \edef\ans{\expandafter\nxtopt\optlist@@}\fi
  88.   \swtrue \loop
  89.     \edef\temp{\expandafter\nxtopt\optlist@@}%
  90.     \edef\optlist{\expandafter\rstopt\optlist@@}%
  91.     \if\temp?\swfalse\else
  92.       \if\temp\ans\wropt\ans
  93.           \else\wrxopt\temp
  94.       \fi
  95.       \expandafter\let\csname opt@\temp\endcsname\relax
  96.     \fi
  97.   \ifsw \repeat
  98.   \def\optlist{?,}%
  99.   \wr{\pc--------------------}%
  100.   }
  101. \def\wropt#1{\edef\tempx{\csname opt@#1\endcsname}\if!\tempx!
  102.   \wr{\spsp\spsp\pc: (def) \csname txt@#1\endcsname}\else
  103.   \wr{\spsp\sep\csname opt@#1\endcsname\pc: \csname txt@#1\endcsname}
  104.     \def\sep{,}\fi
  105.   \mes{\spsp You have selected: \csname txt@#1\endcsname}}
  106. \def\wrxopt#1{\edef\tempx{\csname opt@#1\endcsname}\if!\tempx!
  107.   \wr{\pc\spsp\pc(def) \csname txt@#1\endcsname}\else
  108.   \wr{\pc\spsp\sep\csname opt@#1\endcsname\pc: \csname txt@#1\endcsname}
  109.     \def\sep{,}\fi}
  110. \mes{***********************************^^J%
  111.      * This is Make Bibliography Style *^^J%
  112.      ***********************************^^J%
  113.      It makes up a docstrip batch job to produce^^J%
  114.      a customized .bst file for running with BibTeX}
  115.  
  116. \ask{\yn}{Do you want a description of the usage? (NO)}
  117.  
  118. \if!\yn!\else\if\yn n\else\if\yn N\else
  119. \mes{In the interactive dialogue that follows,^^J%
  120.      you will be presented with a series of menus.^^J%
  121.      In each case, one answer is the default, marked as (*),^^J%
  122.      and a mere carriage-return is sufficient to select it.^^J%
  123.      (If there is no * choice, then the default is the last choice.)^^J%
  124.      For the other choices, a letter is indicated^^J%
  125.      in brackets for selecting that option. If you select^^J%
  126.      a letter not in the list, default is taken.^^J^^J%
  127.      The final output is a file containing a batch job^^J%
  128.      which may be (La)TeXed to produce the desired BibTeX^^J%
  129.      bibliography style file. The batch job may be editted^^J%
  130.      to make minor changes, rather than running this program^^J%
  131.      once again.}
  132. \fi\fi\fi
  133. \loop
  134.   \def\ans{genbst.mbs}
  135.   \ask{\mfile}{^^JEnter the FULL name of the MASTER file (def=\ans)}
  136.   \if!\mfile!\edef\mfile{\ans}\fi
  137.   \openin\infile\mfile\relax
  138.   \ifeof\infile \def\ans{}\fi \closein\infile
  139.   \if!\ans! \mes{*** Cannot find file `\mfile'}
  140. \repeat
  141. \edef\mroot{\getroot\mfile}
  142. \edef\mext{\getext\mfile}
  143. \edef\temp{\mroot.opt}
  144. \openin\infile\temp\relax
  145. \let\mnext=\mext
  146. \ifeof\infile \else
  147.   \ask{\yn}{** Warning: a file `\temp' also exists^^J
  148.        \spsp Shall I read it for the menu information? (NO)^^J
  149.        \spsp (Answer `yes' only if you really know what you are doing)}
  150. \if\yn y\def\mnext{opt}\else\if\yn Y\def\mnext{opt}\fi\fi
  151. \mes{Menu information read from `\mroot.\mnext}
  152. \fi
  153. \closein\infile
  154. \loop
  155.   \ask{\ofile}{^^JName of the final OUTPUT .bst file?}
  156.   \if!\ofile!\mes{*** There is no default name for the output file}
  157. \repeat
  158. \edef\oroot{\getroot\ofile}
  159. \edef\oext{\getext\ofile}
  160. \if!\oext!\def\oext{bst}\fi
  161. \ask{\ans}{^^JGive a comment line to include in the style file.^^J%
  162.            Something like for which journals it is applicable.}
  163. \immediate\openout\outfile\oroot.dbj
  164. \wr{\pcpc Driver file to produce \oroot.\oext\space from \mroot.\mext}
  165. \wr{\pcpc Generated with \filename, version \fileversion\space (\filedate)}
  166. \wr{\pcpc Produced on \Now}
  167. \wr{\pcpc}
  168. \wr{\string\def\string\batchfile{\oroot.dbj}}
  169. \wr{\string\input\space docstrip}
  170. \wr{}
  171. \wr{\string\preamble}
  172. \wr{----------------------------------------}
  173. \wr{*** \ans\space ***}
  174. \wr{}
  175. \wr{\string\endpreamble}
  176. \wr{}
  177. \wr{\string\postamble}
  178. \wr{End of customized bst file}
  179. \wr{\string\endpostamble}
  180. \wr{}
  181. \wr{\string\keepsilent}
  182. \wr{}
  183. \begingroup\catcode`\{=12 \catcode`\}=12
  184. \catcode`\(=1 \catcode`\)=2
  185. \wr(\string\generateFile{\oroot.\oext}{f}{\string\from{\mroot.\mext}{\pc)
  186. \endgroup
  187. \def\sep{}
  188.  
  189. \edef\temp{\mroot.\mnext}
  190. \openin\infile\temp\relax
  191. \let\endoptions=\endinput
  192. \input\temp
  193. \begingroup\catcode`\{=12 \catcode`\}=12
  194. \catcode`\(=1 \catcode`\)=2
  195. \wr(\spsp}})
  196. \endgroup
  197.  
  198. \immediate\closeout\outfile
  199. \mes{^^JFinished!!^^J%
  200.      Batch job written to file `\oroot.dbj'}
  201. \def\ofile{\oroot.dbj}
  202. \ask{\yn}{Shall I now run this batch job? (NO)}
  203. \def\temp{\relax}
  204. \if!\yn!\else\if\yn n\else\if\yn N\else
  205. \def\temp{\input\ofile}\fi\fi\fi
  206. {\catcode`\@=11 \ifx\@@end\undefined\else
  207.   \global\let\end=\@@end\fi}
  208. \temp
  209. \end
  210. %% <<<<< End of decommented file <<<<<< 
  211. %% 
  212. %% End of file makebst.tex. 
  213.