1\documentclass{article} 2\begin{document} 3\section{Version} 4Running eTeX version \the\eTeXversion\eTeXrevision. 5 6\section{Old style} 7\def\baz{BAZ!} 8baz \expandafter\ifx\csname baz\endcsname\relax IS \else is NOT \fi relax; 9baz \ifx\baz\undefined IS equal \else is NOT equal \fi undefined; 10baz \ifdefined\baz IS \else is NOT \fi defined. 11 12foo \expandafter\ifx\csname foo\endcsname\relax IS \else is NOT \fi relax; 13foo \ifx\foo\undefined IS equal \else is NOT equal \fi undefined; 14foo \ifdefined\foo IS \else is NOT \fi defined. 15 16\section{New style} 17\def\ebaz{BAZ!} 18ebaz \ifcsname ebaz\endcsname IS \else is NOT \fi bound; 19ebaz \ifx\ebaz\undefined IS equal \else is NOT equal \fi undefined; 20ebaz \ifdefined\ebaz IS \else is NOT \fi defined. 21 22efoo \ifcsname efoo\endcsname IS \else is NOT \fi bound; 23efoo \ifx\efoo\undefined IS equal \else is NOT equal \fi undefined; 24efoo \ifdefined\efoo IS \else is NOT \fi defined. 25 26\section{Expansion} 27Regular form: 28\def\When{Now}% 29\edef\Expanded{Was expanded \When}% 30\def\When{Later}% 31Got \Expanded. 32 33With noexpand inserted: 34\def\When{Now}% 35\edef\Expanded{Was expanded \noexpand\When}% 36\def\When{Later}% 37Got \Expanded. 38 39Using the new protected primitive: 40\protected\def\eWhen{Now}% 41\edef\Expanded{Was expanded \eWhen}% 42\protected\def\eWhen{Later}% 43Got \Expanded. 44 45\section{Tokens} 46\detokenize{This_and^that}. 47 48\catcode`*=\active 49\def*{STAR} 50A Shooting *. 51 52\def\Stuff{\unexpanded{A Falling *}.} 53\Stuff 54\def*{from grace} 55\Stuff 56 57\section{Unless} 58\newcount\one\one=1\relax 59\newcount\two\two=2\relax 60\newcount\many\many=99\relax 61 62\newif\ifalwaystrue\alwaystruetrue 63\newif\ifalwaysfalse\alwaysfalsefalse 64 65\ifnum\one>\two 1 greather than 2 \else not 1 greater than 2\fi. 66\ifnum\many>\two many greater than 2 \else not many greater than 2\fi. 67 68True \ifalwaystrue is always true \else should never be false\fi. 69False \ifalwaysfalse should never be true \else is always false\fi. 70 71\ifodd\one one is odd\else one is not odd\fi. 72\ifodd\two two is odd\else two is not odd\fi. 73 74one is \ifcase\one zero \or one \or two \or three \else many\fi. 75two is \ifcase\two zero \or one\or two\or three \else many\fi. 76many is \ifcase\many zero \or one\or two\or three \else many\fi. 77 78 79INVERT \unless\ifnum\one>\two 1 greater than 2 \else not 1 greater than 2\fi. 80INVERT \unless\ifnum\many>\two many greater than 2 \else not many greater than 2\fi. 81 82INVERT \unless\ifodd\one one is odd\else one is not odd\fi. 83INVERT \unless\ifodd\two two is odd\else two is not odd\fi. 84 85INVERT True \unless\ifalwaystrue is always true \else should never be false\fi. 86INVERT False \unless\ifalwaysfalse should never be true \else is always false\fi. 87 88% You cannot use \unless before \ifcase! 89% You cannot use \unless before a macro (even if it expands to \if...) 90 91\section{Registers} 92\newbox\mybox 93\newdimen\mydima 94\newdimen\mydimb 95\def\mywidth{\wd\mybox} 96\protected\def\protectedmywidth{\wd\mybox} 97\setbox\mybox\hbox{Some Text} 98\the\mywidth 99 100\mydima\mywidth 101Width:\the\mydima 102 103\mydimb\protectedmywidth 104Width:\the\mydimb 105 106\input{etex-mydim}\mywidth 107Width:\the\mydima 108 109\def\mypts{pt} 110\def\myminus{-} 111\def\myone{1} 112\def\mytwo{2} 113\mydima\myminus\myone\mytwo\mypts\relax 114Width:\the\mydima 115 116\protected\def\protectedmypts{pt} 117\protected\def\protectedmyminus{-} 118\protected\def\protectedmyone{1} 119\protected\def\protectedmytwo{2} 120\mydima\protectedmyminus\protectedmyone\protectedmytwo\protectedmypts\relax 121Width:\the\mydima 122 123\end{document} 124\end{document}