Category : EmTeX is a TeX/LaTeX document editor
Archive   : LATEX.ZIP
Filename : IFTHEN.DOC

 
Output of file : IFTHEN.DOC contained in archive : LATEX.ZIP
% IFTHEN DOCUMENT-STYLE OPTION - released 16 June 1991
% for LaTeX version 2.09
% Copyright (C) 1991 by Leslie Lamport

\typeout{Document Style Option 'ifthen' -- Released 16 June 1991.}

% \ifthenelse{TEST}{THENCLAUSE}{ELSECLAUSE}
% An if-then-else command where
% TEST == \equal{STRING}{STRING}
% number < number | number = number | number > number |
% \(TEST\) | \not TEST | TEST \or TEST | TEST \and TEST
% with \or, \and and \not denoting the obvious logical operators,
% \( and \) as parentheses, and \equal testing equality of strings.
%
% \equal{STRING}{STRING}
% Tests if the two arguments are equal, after all macros are expanded.
% E.g.: \def\foo{bar} ... causes \equal{\foo}{bar} to evaluate to `true'
%
% \whiledo{TEST}{DO-CLAUSE}
% A while-do construction, with TEST the same as above.
%
% \ifthenelse{TEST}{THEN-CLAUSE}{ELSE-CLAUSE} ==
% BEGIN
% \@tempboxa := \vbox{ \protect := \noexpand
% \or := \@or
% \and := \@and
% \not := \@neg
% \( := \@lparen
% \) := \@rparen
% \@eval \ifnum
% eval(TEST) %%% \if's not expanded
% @term := T \else @term := F \fi
% \@endeval
% @gtempa :=G @val }
% IF @gtempa = T THEN THEN-CLAUSE
% ELSE ELSE-CLAUSE FI
% END
%
% \@eval == BEGIN @val := F
% @orop := T
% @negate := F
% END
%
% \@endeval ==
% BEGIN
% IF \@negate =T THEN \@negate := F
% IF \@term = T THEN \@term := F
% ELSE \@term := T
% FI FI
% IF \@orop = T THEN IF \@val = F
% THEN \@val := \@term FI
% ELSE IF \@val = T THEN \@val := \@term FI
% FI
%
% \@or ==
% BEGIN @term := T \else @term := F \fi
% \@endeval
% \@orop := T
% \ifnum
% END
%
% \@and ==
% BEGIN \relax \@term := T \else \@term := F \fi
% \@endeval
% \@orop := F
% \ifnum
% END
%
% \@neg == BEGIN 1=1 \fi
% \@negate := T
% \ifnum
% END
%
% \@lparen == BEGIN 1=1 \fi
% \begingroup
% \@eval \ifnum
% END
%
% \@rparen ==
% BEGIN \relax \@term := T \else \@term := F \fi
% \@endeval
% IF \@val = T THEN \@gtempb :=G 1=1
% ELSE \@gtempb :=G 1=0 FI
% \endgroup
% \ifnum
% \@gtempb
%
% \equal{STR1}{STR2} ==
% BEGIN 1=1 \fi
% \@tempa := eval(STR1)
% \@tempe := eval(STR2)
% IF \@tempa == \@tempe
% THEN \@tempa := 1=1
% ELSE \@tempa := 1=0 FI

% \ifnum \@tempa
% END
%
% \whiledo{TEST}{DO-CLAUSE} ==
% \ifthenelse{TEST}{@whiledo := true
% WHILE @whiledo
% DO DO-CLAUSE
% \ifthenelse{TEST}{@whiledo := true}
% {@whiledo := false}
% OD}
% {}

\long\def\ifthenelse#1#2#3{\setbox\@tempboxa
\vbox{\let\protect\noexpand
\let\or\@or \let\and\@and \let\not\@neg
\let\(\@lparen \let\)\@rparen
{\let\if\relax\let\ifx\relax\let\ifnum\relax\let\fi\relax
\let\else\relax \xdef\@gtempa{#1}}\expandafter
\@eval \ifnum \@gtempa\relax \def\@term{T}\else \def\@term{F}\fi
\@endeval\global\let\@gtempa\@val}\if\@gtempa T#2\else#3\fi}

\def\@eval{\def\@val{F}\def\@orop{T}\def\@negate{F}}

\def\@endeval{\if\@negate T\def\@negate{F}\if\@term T\def\@term{F}\else
\def\@term{T}\fi\fi
\if\@orop T\if\@val F\let\@val\@term\fi
\else \if\@val T\let\@val\@term\fi\fi}

\def\@or{\relax\def\noexpand\@term{T}\else \def\noexpand\@term{F}\fi
\noexpand\@endeval \def\noexpand\@orop{T}\ifnum}

\def\@and{\relax\def\noexpand\@term{T}\else \def\noexpand\@term{F}\fi
\noexpand\@endeval\def\noexpand\@orop{F}\ifnum}

\def\@neg{1=1 \fi \def\noexpand\@negate{T}\ifnum}

\def\@lparen{1=1 \fi \begingroup \noexpand\@eval \ifnum}

\def\@rparen{\relax\def\noexpand\@term{T}\else \def\noexpand\@term{F}\fi
\noexpand\@endeval
\if\noexpand\@val T\gdef\noexpand\@gtempb{1=1}\else
\gdef\noexpand\@gtempb{1=0}\fi
\endgroup \ifnum\noexpand\@gtempb}

\def\equal#1#2{1=1 \fi \edef\noexpand\@tempa{#1}%
\edef\noexpand\@tempe{#2}\ifx
\noexpand\@tempa\noexpand\@tempe
\def\noexpand\@tempa{1=1}\else
\def\noexpand\@tempa{1=0}\fi \ifnum \noexpand\@tempa}

\long\def\whiledo#1#2{\ifthenelse{#1}{\@whiledotrue \@whilesw\if@whiledo
\fi{#2\ifthenelse{#1}{\@whiledotrue}{\@whiledofalse}}}{}}

\newif\if@whiledo

\endinput


  3 Responses to “Category : EmTeX is a TeX/LaTeX document editor
Archive   : LATEX.ZIP
Filename : IFTHEN.DOC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/