÷ƒ’À;è TeX output 1996.03.05:1542‹ÿÿÿÿ <æ� ýÊ}ü ‚� þ-}þ�’ΡTó0X«Q cmr12ÛIn�¬rteraction–ê¨to�SŽols:‘8àó6߆µT cmtt12ádialog.sty“Ûand“ámenus.styŽŸ�����’§'ÛMic•¬rhael‘ê¨Do“wnesŽŽŽŽŽŸˆ‹�’2]No•¬rv“em“b�SŽer–ê¨3,“1994Ž �ùv�� þ‡[ß�‘Õºâó5ÂÖN  cmbx12àIn� tro�`ductionŽŸ!«Ë�‘ÕºâóKñ`y cmr10²This–[Varticle“describ�Ges“ó$ßêŸ'EŽ‘ãxX“do�Gcumen•¸ãtst“yleŽ¡�‘Õºâoption–w9 les,‘±but“in“writing“them“I‘w0sp�Genš¸ãt“some“extra“e ort“to“try“to“mak˜e“them“us-Ž¡�‘Õºâable–ÑÂwith“ó[Œ-ø cmcsc10ë[plain›ª®²T�‘þU>Ÿ'EŽ‘ãxX“or“other“common“macro“pac�¸ãk‘ÿqÇages“that“include“ë[plain˜²T�‘þU>Ÿ'EŽ‘ãxX“inŽ¡�‘Õºâtheir–UUbase,“suc�¸ãh“as�“ó !",š cmsy10¸A�‘þŸžqMŽ‘QS‘¿ü²-T�‘þU>Ÿ'EŽ‘ãxXŽ‘3hùor“ë[Eplain².Ž©RÈ�‘äºâThe–ò/appšGendix“describ˜es“Ïgrabhedr.sty²,›Ydrequired“b�¸ãy“Ïdialog.sty²,˜whic�¸ãh“pro-Ž¡�‘Õºâvides›­æt•¸ãw“o˜useful˜ le-handling˜features:‘"é(1)˜a˜command˜Ï\inputfwh˜²that˜when˜sub-Ž¡�‘Õºâstituted–äÍfor“Ï\input“²makš¸ães“it“p�Gossible“to“grab“information“suc˜h“as“ le“name,‘ûOv˜ersion,Ž¡�‘Õºâand–Ó8date“from“standardized“ le“headers“in“the“stš¸ãyle“promoted“b˜y“Nelson“Beeb�Ge|Ž¡�‘Õºâand–Œto“grab“it“in“the“prošGcess“of“ rst“inputting“the“ le,‘ÙÈas“opp˜osed“to“inputtingŽ¡�‘Õºâthe–gò le“t�¸ãwice,‘¬™or“Ï\read²ing“the“information“separately“(unreliable“due“to“system-Ž¡�‘Õºâdep�Gendenš¸ãt–>^di erences“in“the“equiv‘ÿqÇalence“of“T�‘þU>Ÿ'EŽ‘ãxX's“Ï\input“²searc˜h“path“and“Ï\openinŽ¡�‘Õºâ²searcš¸ãh–Y+path).‘¹And“(2)“functions“Ï\localcatcodes“²and“Ï\restorecatcodes“²that“mak˜eŽ¡�‘Õºâit–×ap�Gossible“for“Ïdialog.sty“²(or“anš¸ãy“ le)“to“manage“in˜ternal“catco�Gde“c˜hanges“prop-Ž¡�‘Õºâerly–UUregardless“of“the“surrounding“con�¸ãtext.ަ�‘äºâThese–›_ les“and“a“few“others“are“comš¸ãbined“in“a“suite“of“ les“that“go�Ges“b˜y“the“nameŽ¡�‘Õºâof–éaó#ò"V cmbx10Îdialogl²,‘daš¸ãv‘ÿqÇailable“on“the“In˜ternet“b˜y“anon˜ymous“ftp“from“CT‘ÿ*ªAN‘é;(Comprehen-Ž¡�‘Õºâsivš¸ãe–#JT�‘þU>Ÿ'EŽ‘ãxX“Arc˜hiv˜e“Net˜w˜ork),–-Le.g.,“Ïftp.shsu.edu–#J²(USA),“or“Ïftp.uni-stuttgart.deŽ¡�‘Õºâ²(Europ�Ge).‘_þThe–ù le“Ïlistout.tex“²is“a“utilitš¸ãy“for“v˜erbatim“prin˜ting“of“plain“text“ les,Ž¡�‘Õºâwith–�Œreasonably“go•Go“d–�Œhandling“of“o•¸ãv“erlong–�Œlines,›ŸYtab“c�¸ãharacters,˜other“nonprin�¸ãtingŽ¡�‘Õºâcš¸ãharacters,‘hõetc.‘ àIt–euses“Ïmenus.sty“²to“presen˜t“an“elab�Gorate“men˜u“system“for“c˜hang-Ž¡�‘Õºâing–+¨options“(likš¸ãe“fon˜t“size,›3þline“spacing,˜or“hoš¸ãw“man˜y“spaces“should“b�Ge“prin˜ted“for“aŽ¡�‘Õºâtab‘UUc�¸ãharacter).ަ�‘äºâHere's–ýan“example“from“the“men�¸ãu“system“of“Ïlistout.tex“²to“demonstrate“theŽ¡�‘Õºâuse–û?of“some“features“from“Ïdialog.sty“²and“Ïmenus.sty².‘c…First,‘$¹the“menš¸ãu“that“y˜ouŽŽ� þ‡[ß�’J7 wš¸ãould–UUsee“if“y˜ou“w˜an˜ted“to“c˜hange“the“fon˜t“or“line“spacing:Ž©�’J7 Ï===============================================ޤ ŒÉ�’T·F‘ úChange‘?ýfontŽ¡�’T·S‘ úChange–?ýfont“sizeŽ¡�’T·L‘ úChange–?ýline“spacingޤ’�’J7 Current–?ýsettings:“typewriter“8“/“10.0pt.Ž¡�’_7Q– úQuit‘/?åX“Exit‘)ÿè?“HelpŽŸ ŒÉ�’J7 ===============================================Ž¡�’J7 Your‘?ýchoice?ŽŸ‡I�’J7 ²Supp�Gose–'%yš¸ãou“w˜an˜ted“to“c˜hange“line“spacing“to“9“p�Goin˜ts,‘[˜so“y˜ou“en˜tered“Ïl“²(lo˜w˜er-ޤ �’J7 case–ƒ0ÏL²)“and“then“Ï9pt²,‘ާexcept“that“on“yš¸ãour“ rst“attempt“y˜ou“acciden˜tally“mist˜yp�GedŽ¡�’J7 Ï9pe–UU²instead“of“Ï9pt².‘qÇHere's“what“yš¸ãou“w˜ould“see“on“screen:ަ�’J7 ÏYour–?ýchoice?“lޤ ŒÉ�’J7 Desired–?ýline“spacing“[TeX“units]“?“9peŽ¡�’J7 ?---I–?ýdon't“understand“"9pe".Ž¡�’J7 Desired–?ýline“spacing“[TeX“units]“?“9ptŽŸ’�’J7 *–?ýNew“line“spacing:“9.0ptŽŸ‡I�’J7 ²Both›) lo•¸ãw“ercase˜Ïl˜²and˜capital˜ÏL‘(Ô²are˜acceptable˜resp�Gonses,‘]øand˜the˜v‘ÿqÇalue˜giv“en˜forޤ �’J7 line–+Ôspacing“is“c•¸ãhec“k“ed–+Ôto“makš¸ãe“sure“it's“a“v‘ÿqÇalid“T�‘þU>Ÿ'EŽ‘ãxX“dimension.‘õDBefore“con˜tin˜u-Ž¡�’J7 ing,‘}‡the–u}inš¸ãternalized“v˜ersion“of“the“user's“v‘ÿqÇalue“is“ec˜ho�Ged“on“screen“to“con rm“thatŽ¡�’J7 the–UUenš¸ãtered“v‘ÿqÇalue“w˜as“read“correctly‘ÿ*ª.Ž¡�’Y7 Noš¸ãw–2 here's“ho˜w“the“ab�Go˜v˜e“men˜u“is“programmed“in“Ïlistout.tex².‘ëA‘1ÓfunctionŽ¡�’J7 Ï\menuF–UU²is“constructed“using“Ï\fxmenu²:ަ�’J7 Ï\fxmenu\menuF{}{ޤ ŒÉ�’J7 F‘ úChange‘?ýfontŽ¡�’J7 S‘ úChange–?ýfont“sizeŽŽŽŽŽŒ‹* <æ� ýÊ}ü��’Ò!Dóo´‹Ç cmr9ÅINTERA�¾9CTION–TTOOLS:“óߤN cmtt9ÊDIALOG.STY“ÅAND“ÊMENUS.STY’üfb²2ŽŽ ‚��� þ }ü�‘ÕºâÏL‘ úChange–?ýline“spacingޤ ŒÉ�‘Õºâ}{Ž¡�‘ÕºâCurrent–?ýsettings:“&\mainfont“&\mainfontsize“/“%Ž¡�‘Õºâ&\the&\normalbaselineskip.Ž¡�‘Õºâ}Ž¡�‘Õºâ%Ž¡�‘Õºâ\def\moptionF{\lettermenu‘?ýF}Ž©Nl�‘Õºâ²In–Q“the“de nition“of“Ï\moptionF²,‘…‡Ï\lettermenu“²is“a“high-lev�¸ãel“function“from“Ïmenus.styޤ �‘Õºâ²that–#Åprinš¸ãts“Ï\menuF“²on“screen“(giv˜en“the“argumen˜t“ÏF²),“reads“a“line“of“input“from“theŽ¡�‘Õºâuser,›4Õextracts–"the“ rst“c�¸ãharacter“and“forces“it“to“upp�Gercase,˜then“branc�¸ãhes“to“theŽ¡�‘Õºânext–�menš¸ãu“as“determined“b˜y“that“c˜haracter.‘ The“resp�Gonse“of“Ïl“²causes“a“branc˜h“toŽ¡�‘Õºâthe–UUfunction“Ï\moptionFL²:ŽŸõZ�‘ÕºâÏ\def\moptionFL{%ޤ ŒÉ�‘à:Ü\promptmesj{%Ž¡�‘êºÖDesired–?ýline“spacing“[TeX“units]“?“}%Ž¡�‘à:Ü\readline{Q}\replyަ�‘Õºâ²If–‘˜ÏQ²,“ÏX²,“or“Ï?“²wš¸ãas“en˜tered,‘ ©the“test“Ï\xoptiontest“²will“return“`true';‘¯ºthen“w˜e“shouldޤ �‘Õºâskip–?Pthe“dimension“c•¸ãhec“king–?Pand“go“directly“to“Ï\optionexec²,‘C·whicš¸ãh“kno˜ws“what“toŽ¡�‘Õºâdo–UUwith“those“resp�Gonses:ŽŸõZ�‘à:ÜÏ\if\xoptiontest\replyŽŸ ŒÉ�‘à:Ü\elseަ�‘Õºâ²Otherwise–þwš¸ãe“c˜hec˜k“the“giv˜en“dimension“to“mak˜e“sure“it's“usable.‘kËIf“so,‘(,ec˜ho“theŽ¡�‘Õºânew–UUv‘ÿqÇalue“as“con rmation.ŽŸõZ�‘êºÖÏ\checkdimen\reply\dimen@ޤ ŒÉ�‘êºÖ\ifdim\dimen@>\z@Ž¡�‘õ:Ð\normalbaselineskip\dimen@\relaxŽ¡�‘õ:Ð\normalbaselinesŽ¡�‘õ:Ð\confirm{New–?ýline“spacing:Ž¡��ºÊ\the\normalbaselineskip}%Ž¡�‘õ:Ð\def\reply{Q}%Ž¡�‘êºÖ\fiަ�‘Õºâ²If–³‰Ï\reply“²wš¸ãas“c˜hanged“to“ÏQ‘³.²during“the“ab�Go˜v˜e“step,‘ Ï\optionexec“²will“p�Gop“bac˜kޤ �‘Õºâup–® to“the“previous“menš¸ãu“lev˜el“(normal“con˜tin˜uation);‘Úcotherwise“Ï\reply“²retains“itsŽ¡�‘Õºâprior–­de nition|e.g.,‘ÃÏ9pe²|to“whicš¸ãh“Ï\optionexec“²will“simply“sa˜y“\I‘¬ýdon't“under-Ž¡�‘Õºâstand–UUthat"“and“rep�Geat“the“curren�¸ãt“prompt.ŽŸõZ�‘à:ÜÏ\fiޤ ŒÉ�‘à:Ü\optionexec\replyŽ¡�‘Õºâ}ŽŽ� þ }ü�’Y7 ²F‘ÿ*ªor–_®maximš¸ãum“p�Gortabilit˜y‘ÿ*ª,‘bDÏlistout.tex“²uses“in“its“men˜us“only“lo˜w˜est-common-ޤ �’J7 denominator–é ordinary“prinš¸ãtable“ASCI�GI‘è£c˜haracters“in“the“range“32{126.‘ ,êF‘ÿ*ªancierŽ¡�’J7 men�¸ãus–¯1can“bšGe“obtained“at“a“cost“of“forgoing“system“indep˜endence,‘Ũfor“instance“b�¸ãyŽ¡�’J7 using–.}emT�‘þU>Ÿ'EŽ‘ãxX's“Ï/o“²option“to“output“the“b�Go•¸ãx-dra“wing›.}c“haracters˜in˜the˜standard˜PCŽ¡�’J7 DOS–UUc�¸ãharacter“set.ŽŸÿª�’J7 àNotationŽŸuÖ�’J7 ²Double-hat–Xµnotation“sucš¸ãh“as“Ï^^J‘Xr²is“used“herein“for“con˜trol“c˜haracters,‘™�as“in“ó!ý': cmti10ÌTheŽ¡�’J7 T�‘þKß'EŽ‘Í-Xb–ÿ}'o“ok²,‘:¦although– Éo�Gccasionally“the“alternate“form“`ë[contr�Çol²-J'‘ šis“used“when“theŽ¡�’J7 emphasis–†Ûis“a•¸ãw“a“y–†Ûfrom“the“cš¸ãharacter's“tok˜enized“state“inside“T�‘þU>Ÿ'EŽ‘ãxX.‘XA‘†Îcouple“of“ab-Ž¡�’J7 breviations–°ßfrom“Ïgrabhedr.sty“²are“used“frequen�¸ãtly“in“the“macro“co�Gde:‘(ÚÏ\xp@“²=Ž¡�’J7 Ï\expandafter²,‘FÚand–ŒÏ\nx@“²=“Ï\noexpand².‘µlStandard“abbreviations“from“Ïplain.texŽ¡�’J7 ²sucš¸ãh–UUas“Ï\z@“²or“Ï\toks@“²are“used“without“sp�Gecial“commen˜t.ŽŸ9&�’J7 àP� art‘€1ŽŸF�’J7 Basic–€dialog“functions:‘ádialog.styŽŸêî��’J7 à1.1Ž’h÷ HistoryŽŸç��’J7 ²This›ä le,–úÅÏdialog.sty²,“w•¸ãas˜b�Gorn˜out˜of˜a˜utilit“y˜called˜Ïlistout.tex˜²that˜I‘äwrote˜forŽ¡�’J7 m�¸ãy–œ+pšGersonal“use.‘FIThe“purp˜ose“of“Ïlistout.tex“²wš¸ãas“to“facilitate“prin˜ting“out“plainŽ¡�’J7 text–}¤ les|electronic“mail,‘‡¸program“source“ les“in“v‘ÿqÇarious“programming“languages,Ž¡�’J7 and,–<'foremost,“T�‘þU>Ÿ'EŽ‘ãxX– ýmacro“ les“and“log“ les.‘›¿An“imp�Gortanš¸ãt“part“of“m˜y“T�‘þU>Ÿ'EŽ‘ãxX“pro-Ž¡�’J7 gramming–3mpractice“is“to“prin�¸ãt“out“a“macro“ le“on“pap�Ger“and“read“it“through,‘:5mark-Ž¡�’J7 ing–tPcorrections“along“the“w•¸ãa“y‘ÿ*ª,‘|then–tPuse“the“markš¸ãed“cop˜y“as“a“script“for“editing“theŽ¡�’J7 le.‘Þ(F‘ÿ*ªor–$one“thing,‘WÍthis“allo�¸ãws“me“to“analyze“and“mark“corrections“while“ridingŽ¡�’J7 the–óPbus“to“wš¸ãork,‘Îor“sitting“out“in“the“bac˜k“y˜ard“to“sup�Gervise“the“kids.)‘K·The“out-Ž¡�’J7 put–ÍI‘¡normally“desired“wš¸ãas“t˜w˜o“`pages'“pšGer“sheet“of“U.S.“letter-size“pap˜er“prin�¸ãtedŽ¡�’J7 landscapšGe,–UUin“order“to“conserv�¸ãe“pap˜er.Ž© F�’Y7 Once–Üïcreated,‘þÖÏlistout.tex“²quicš¸ãkly“b�Gecame“m˜y“fa˜v˜orite“means“of“prin˜ting“outŽ¡�’J7 plain–´text“ les,‘1Ìnot“to“men�¸ãtion“an“indispšGensable“to˜ol“in“m�¸ãy“debugging“to˜olb˜o�¸ãx:‘Ò…IŽ¡�’J7 turn–«´on“Ï\tracingmacros“²and“Ï\tracingcommands²,‘ÁLthen“prin�¸ãt“out“the“resulting“logŽ¡�’J7 le–Xso“that“I‘Xcan“see“sevš¸ãeral“h˜undred“lines“of“the“log“at“once“(b˜y“spreading“out“t˜w˜oŽ¡�’J7 or–ÞXthree“pages“on“m�¸ãy“desk“with“100+“lines“p�Ger“page);‘"Ùthen“I‘Þ5trace“through,‘˜crossŽ¡�’J7 things–UUout,“lab�Gel“other“things,“draš¸ãw“arro˜ws,“and“so“forth.ަ�’Y7 I‘<ïsošGon–<õadded“a“ lename“prompting“lo˜op“to“makš¸ãe“it“con˜v˜enien˜t“to“prin˜t“m˜ultipleŽ¡�’J7 les–î1in“a“single“run.‘<[In“the“prošGcess“of“p˜erfecting“this“simple“prompting“routine|Ž¡�’J7 o•¸ãv“er›ƒ8t“w“o˜or˜three˜y“ears|and˜adding˜the˜abilit“y˜to˜optionally˜sp�Gecify˜things˜lik“eŽ¡�’J7 n•¸ãum“b�Ger– Žof“columns“at“run“time,‘6œev•¸ãen“tually– ŽI‘ `wrote“so“m•¸ãuc“h– Ždialog-related“macroŽ¡�’J7 cošGde–à;that“it“b˜ecame“clear“this“co˜de“should“b˜e“mo•¸ãv“ed–à;out“of“Ïlistout.tex“²in�¸ãto“itsŽ¡�’J7 oš¸ãwn–UUmo�Gdule.‘qÇThe“result“w˜as“Ïdialog.sty².ŽŽŽŽŽŒ‹ <æ� ýÊ}ü��’Ò!DÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’üfb²3ŽŽ ‚�ŸðO]�� þ.Ÿ�‘äºâBefore–É`getting“inš¸ãto“the“macro“de nitions“and“tec˜hnical“commen˜tary‘ÿ*ª,‘å^here“are“de-ޤ �‘Õºâscriptions–UUfrom“the“user's“p•Gersp“ectiv�¸ãe–UUof“the“functions“de ned“in“this“ le.ŽŸ��‘Õºâà1.2Ž‘ôzâMessage-sending‘€functionsŽŸgD����‘ÕºâŸöÌ͉ffGv¡Ÿ ff�„ ffff�ŸûÌÍ���‘³3Ï\mesj{�¸hó`ßêŸ'EŽ‘ãxX“catcošGdes“to“mak�¸ãe“it“p˜ossible“to“use“most“normal“T�‘þU>Ÿ'EŽ‘ãxXޤ �‘Õºâcommands,–Ô6and›³îcommen�¸ãts,“in˜the˜message˜text.‘;úÏ^^I˜²and˜Ï^^M˜²are˜catco•Gde˜13˜and˜b“e-Ž¡�‘Õºâha•¸ãv“e–(Ças“describšGed“for“Ï\mesj².‘ìThe“Ï&“²is“a“sp˜ecial“con•¸ãv“enience,‘]£an–(Çabbreviation“forŽ¡�‘ÕºâÏ\noexpand²,–UUto“use“for“con�¸ãtrolling“expansion“inside“the“message“text.ަ�‘äºâDoubled–ÊVbacš¸ãkslash“Ï\\“²in“the“argumen˜t“will“pro�Gduce“a“single“category“12“bac˜k-Ž¡�‘Õºâslash›iÝc•¸ãharacter|th“us,‘˜öÏ\\xxx˜²can˜b�Ge˜used˜instead˜of˜Ï\string\xxx˜²or˜Ï\noexpand\xxxŽ¡�‘Õºâ²(notice–úžthat“this“wš¸ãorks“ev˜en“for“outer“things“lik˜e“Ï\bye“²or“Ï\newif²).‘SŠSimilarly“Ï\%²,‘ ÃÏ\{²,Ž¡�‘ÕºâÏ\}–UU²and“Ï\&“²prošGduce“the“corresp˜onding“single“c�¸ãharacters.ަ�‘äºâCategory–UU12“space“means“that“yš¸ãou“cannot“write“something“lik˜eŽŽ� þ.Ÿ�’OwÏ\ifvmode–?üh\else“v\fi“ruleŽ©yŽ�’J7 ²in–AHthe“argumen�¸ãt“of“Ï\xmesj“²without“getting“a“space“after“the“Ï\ifvmode²,–EKÏ\else²,“andޤ �’J7 Ï\fi².��Ÿü^ÿ±1ŽŽ‘  M²Since–;[ošGccasionally“this“ma�¸ãy“b˜e“troublesome,‘tÝÏ\.“²is“de ned“inside“the“argu-Ž¡�’J7 menš¸ãt–d¦of“Ï\xmesj“²to“b�Ge“a“`con˜trol“w˜ord“terminator':‘�iIf“the“expansion“of“Ï\foo“²is“Ïabc²,Ž¡�’J7 then–wCÏ\foo\.xyz“²prošGduces“Ïabcxyz“²on“screen“(as“opp˜osed“to“Ï\foo‘?ýxyz“²whicš¸ãh“w˜ouldŽ¡�’J7 prošGduce–UUÏabc‘?ýxyz²).‘qÇTh�¸ãus“the“ab˜o•¸ãv“e–UUconditional“could“b˜e“written“asަ�’OwÏ\ifvmode\.h\else\.v\fi\.ruleަ�’J7 ²Evš¸ãen–Kithough“the“catco�Gde“c˜hanges“done“b˜y“Ï\xmesj“²setup“ha˜v˜e“no“e ect“if“Ï\xmesj“²isŽ¡�’J7 used–óinside“an“argumenš¸ãt“or“de nition“replacemen˜t“text,‘ I‘óV nd“it“con˜v˜enien˜t“o�Gcca-Ž¡�’J7 sionally–éíto“use“Ï\xmesj“²in“those“con�¸ãtexts,‘ÿhin“order“to“get“other“asp�Gects“of“the“Ï\xmesjŽ¡�’J7 ²setup.‘GìF‘ÿ*ªor–×Äinstance,‘ðáif“yš¸ãou“need“to“em˜b�Ged“a“message“that“con˜tains“a“p�Gercen˜t“sign“in-Ž¡�’J7 side–UUa“de nition,“y�¸ãou“can“writeަ�’OwÏ\def\foo{...Ž¡�’Y÷\xmesj{...–?üthis“is“a“percentŽ¡�’dvøsign:–?ü\%“(sans“backslash)“...}Ž¡�’Ow...}ަ�’J7 ²T‘ÿ*ªo–— further“supp�Gort“sucš¸ãh“uses“of“Ï\xmesj²,‘çzthe“follo˜wing“c˜hanges“are“also“done“b˜yŽ¡�’J7 Ï\xmesj–öÕ²setup:‘B‡the“bacš¸ãkslash-space“con˜trol“sym˜b�Gol“Ï\ “²is“made“equiv‘ÿqÇalen˜t“to“Ï\space²;Ž¡�’J7 Ï\ –¸$²and“Ï\ “²are“de ned“to“pro�Gduce“a“Ï\newlinechar²;‘i‹and“activ�¸ãe“tilde“Ï~“²will“pro-Ž¡�’J7 duce–UUa“category-12“tilde.Ž¡�’Y7 Among–içother“things,‘o this“setup“makš¸ães“it“easier“to“obtain“newlines“and“m˜ultipleŽ¡�’J7 spaces–œéin“an“emš¸ãb�Gedded“message.‘H„F‘ÿ*ªor“example,‘®Îin“the“follo˜wing“de nition“the“mes-Ž¡�’J7 sage–Îwill“ha•¸ãv“e–Îa“line“break“on“screen“for“eacš¸ãh“bac˜kslash“at“the“end“of“a“line,‘and“theŽ¡�’J7 third–UUline“will“b�Ge“inden�¸ãted“four“spaces.ަ�’OwÏ\def\bar{...Ž¡�’Y÷\xmesj{First‘?üline\Ž¡�’dvøSecond‘?üline\Ž¡�’dvø\–?ü\“\“\“Indented“line\Ž¡�’dvøLast‘?üline}%Ž¡�’Ow...}ަ�’J7 ²The– lalternativ�¸ãe“of“de ning“a“separate“message“function“Ï\barfoo“²with“Ï\f[x]mesjŽ¡�’J7 ²and– †calling“Ï\barfoo“²inside“of“Ï\bar“²wš¸ãould“allo˜w“more“natural“en˜try“of“the“new-Ž¡�’J7 lines–¸Úand“the“mš¸ãultiple“spaces,‘Ѽbut“w˜ould“b�Ge“sligh˜tly“more“exp�Gensiv˜e“in“string“p•Go“olŽ¡�’J7 and–UUhash“table“usage.ŽŸî����’J7 ŸêÌ͉ffl6ŒŸff�„ffff�ŸûÌÍ��Ÿô�‘³3Ï\promptmesj{�¸hë`text‘¼r¸iŽ‘ƒ„Ï}Ž¡�‘³3\promptxmesj{�¸hë`text‘¼r¸iŽ‘ƒ„Ï}ŽŽŽŽ‘kiÀ„ffffŽžff‰ffl6ŒŽŽŽŽ¦�’J7 ²These–“oare“lik�¸ãe“Ï\mesj²,‘¢õÏ\xmesj“²but“use“Ï\message“²rather“than“Ï\immediate\write16Ž¡�’J7 ²in•¸ãternally‘ÿ*ª,›9Øth“us–2øif“the“follo�¸ãwing“op�Geration“is“a“Ï\read²,˜the“user“will“see“the“cursor“onŽŽŽ‘ÕºâŸff‰ff%ûÇŸ J=����‘ "5Ÿý-:ó¹Aa¨cmr6º1ŽŽŽ‘LÜó|{Ycmr8ÀW–ÿJªell,›ÕXactually“,˜y•ÃŽou˜could˜replace˜eac“h˜space˜b“y˜óLßCÊscmtt8ëL%�ó¾KÈ cmsy8Âhó#Ñf�cmti8Ãnew�p[line‘™šÂiŽ‘&’ŒÀto˜get˜rid˜of˜it.‘Ç But˜that˜mak“es˜the˜message˜text˜harder˜to˜read˜for˜the˜programmer.ŽŽŽŒ‹(ª <æ� ýÊ}ü��’Ò!DÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’üfb²4ŽŽ ‚��� þ }ü�‘Õºâscreen–,vat“the“end“of“the“last“line,‘4¢as“ma�¸ãy“b�Ge“desired“when“prompting“for“a“short“re-ޤ �‘Õºâply‘ÿ*ª,‘Bmrather–than“at“the“b�Geginning“of“the“next“line.‘ªÎThe“c�¸ãharacter“Ï!“²is“preemptedŽ¡�‘Õºâinš¸ãternally–^for“newlinec˜har,‘1`for“these“t˜w˜o“functions“only‘ÿ*ª,‘1`whic˜h“means“that“it“can-Ž¡�‘Õºânot–êb�Ge“actually“prinš¸ãted“in“the“message“text.‘/ÒUse“of“a“visible“c˜haracter“suc˜h“as“Ï!²,Ž¡�‘Õºârather–Üæthan“the“normal“Ï\newlinechar“^^J²,‘þÊis“necessary“for“robustness“b�Gecause“ofŽ¡�‘Õºâthe–Ü%fact“that“the“Ï\message“²primitivš¸ãe“w˜as“unable“to“use“an“`in˜visible'“c˜haracter“(out-Ž¡�‘Õºâside–|Áthe“range“32{126)“for“newlines“up“unš¸ãtil“T�‘þU>Ÿ'EŽ‘ãxX“v˜ersion“3.1415,‘†›whic˜h“some“usersŽ¡�‘Õºâdo–UUnot“yš¸ãet“ha˜v˜e“(at“the“time“of“this“writing|July“1994).ŽŸ%A¥����‘ÕºâŸêÌ͉ff{öƒŸff�„ffff�ŸûÌÍ��Ÿô�‘³3Ï\storemesj\foo{�¸hë`text‘¼r¸iŽ‘ƒ„Ï}Ž¡�‘³3\storexmesj\foo{�¸hë`text‘¼r¸iŽ‘ƒ„Ï}ŽŽŽŽ‘{)·„ffffŽžff‰ff{öƒŽŽŽŽ©( �‘Õºâ²These–ÖÏfunctions“are“similar“to“Ï\mesj²,‘÷.Ï\xmesj“²but“store“the“giv�¸ãen“text“in“the“con-Ž¡�‘Õºâtrol–Å›sequence“Ï\foo“²instead“of“immediately“sending“the“message.‘˜Standard“T�‘þU>Ÿ'EŽ‘ãxXŽ¡�‘Õºâparameter–)>synš¸ãtax“can“b�Ge“used“to“mak˜e“Ï\foo“²a“function“with“argumen˜ts,‘^8e.g.‘í�af-Ž¡�‘Õºâterޤ³�‘ÚúÞÏ\storemesj\foo#1{...#1...}Ž¡�‘Õºâ²then–UUy�¸ãou“can“later“writeŽ¡�‘ÚúÞÏ\message{\foo{\the\hsize}}Ž¡�‘Õºâ²and–ˆget“the“currenš¸ãt“v‘ÿqÇalue“of“Ï\hsize“²in˜to“the“middle“of“the“message“text.‘vaConse-ޤ �‘Õºâquenš¸ãtly–‚ also“in“the“x-v˜ersion“Ï\storexmesj“²a“category-12“Ï#“²c˜haracter“can“b�Ge“obtainedŽ¡�‘Õºâwith‘UUÏ\#².ަ����‘ÕºâŸ÷[‰ff»òÉŸ ‘�„ ‘ff�Ÿüé���‘³3Ï\fmesj\foobar#1#2...{...#1...#2...}ŽŽŽŽ’»%ý„ ‘ffŽžff‰ff»òÉŽŽŽŽ¦�‘Õºâ²De nes–cÏ\foobar“²as“a“function“that“will“takš¸ãe“the“giv˜en“argumen˜ts,‘-§so˜w“them“in˜toŽ¡�‘Õºâthe–ç©message“text“Ï{...}²,‘ý˜and“send“the“message.‘M9In“the“message“text“all“sp�Gecial“c�¸ãhar-Ž¡�‘Õºâacters–UUare“category“12“except“for“braces,“Ï#²,“tab,“and“carriage“return.ŽŸ Y�‘äºâIf–æ�an“unmatcš¸ãhed“brace“or“a“Ï#“²m˜ust“b�Ge“prin˜ted“in“the“message“text“Ï\fxmesj“²m˜ustŽ¡�‘ÕºâbšGe––wused“instead.‘2((Ï##“²could“b˜e“used“to“insert“a“single“category-6“Ï#“²tokš¸ãen“in˜to“the“mes-Ž¡�‘Õºâsage–û text,‘ *and“T�‘þU>Ÿ'EŽ‘ãxX“wš¸ãould“prin˜t“it“without“an“error,‘ *but“b�Goth“Ï\message“²and“Ï\writeŽ¡�‘Õºâ²w•¸ãould›]prin“t˜it˜as˜t“w“o˜Ï##˜²c“haracters,‘'Áev“en˜though˜it's˜only˜a˜single˜tok“en˜in“ternally‘ÿ*ª.)ަ����‘ÕºâŸ÷[‰ffÁ2ÆŸ ‘�„ ‘ff�Ÿüé���‘³3Ï\fxmesj\foobar#1#2...{...#1...#2...}ŽŽŽŽ’Àeú„ ‘ffŽžff‰ffÁ2ÆŽŽŽŽ¦�‘Õºâ²Comš¸ãbination–óëof“Ï\xmesj“²and“Ï\fmesj².‘QODe nes“Ï\foobar“²lik˜e“Ï\fmesj²,‘gbut“with“full“ex-Ž¡�‘Õºâpansion–åof“the“replacemenš¸ãt“text“and“with“normal“category“co�Gdes“for“bac˜kslash,‘•p�Ger-Ž¡�‘Õºâcenš¸ãt,–Œ?braces,“and–�Chash“Ï#².‘õ’The“con˜trol“sym˜bšGols“Ï\\“\%“\{“\}“\&“²and“Ï\.“²can“b˜e“usedŽ¡�‘Õºâas–UUin“Ï\xmesj²,“with“also“Ï\#“²for“prinš¸ãting“a“Ï#“²c˜haracter“of“category“12.ŽŽ� þ }ü��’J7 à1.3Ž’h÷ Reading‘€functionsŽŸç����’J7 ŸöÌ͉ff�öwŸ ff�„ ffff�ŸûÌÍ���‘³3Ï\readline{�¸hë`default‘¼r¸iŽ‘.C{Ï}\answerŽŽŽŽ’�)«„ ffffŽžff‰ff�öwŽŽŽŽ©­�’J7 ²This–€reads“a“line“of“input“from“the“user“in�¸ãto“the“macro“Ï\answer².‘^Ö(The“macro“nameޤ �’J7 can–m¹b�Ge“anš¸ãything“c˜hosen“b˜y“the“programmer,‘³Ònot“just“Ï\answer².)‘ºôBefore“reading,Ž¡�’J7 all–‚§sp�Gecial“cš¸ãharacters“are“deactiv‘ÿqÇated,‘�üso“that“the“primitiv˜e“Ï\read“²will“not“c˜hok˜e“ifŽ¡�’J7 the–é�user“happ�Gens“to“enš¸ãter“something“lik˜e“Ï\newif“²or“ë[contr�Çol-l“²or“Ï}².‘MÚDep�Gending“onŽ¡�’J7 the–Æ op�Gerating“system,›âµcertain“c�¸ãharacters|e.g.,˜ë[contr•Çol-c²,˜ë[contr“ol-z²,˜ë[contr“ol-Ž¡�’J7 d²,‘í+ë[contr�Çol-h²|migh•¸ãt›Ó!ha“v“e˜sp•Gecial˜e ects˜instead˜of˜b“eing˜en•¸ãtered˜in“to˜the˜replace-Ž¡�’J7 menš¸ãt–‚Ætext“of“Ï\answer²,‘Î"regardless“of“the“catco�Gde“c˜hanges.‘úT‘ÿ*ªo“tak˜e“the“most“ob-Ž¡�’J7 vious–Æwexample,›â¿under“most“op�Gerating“systems,˜t�¸ãyping“ë[contr�Çol-h“²(the“Rub�Gout“orŽ¡�’J7 Bac•¸ãkw“ard-Delete›„=k“ey)˜will˜delete˜the˜previous˜c“haracter˜from˜the˜user's˜resp�Gonse,‘®in-Ž¡�’J7 stead–UUof“enš¸ãtering“an“ë[asci�8ãi“²c˜haracter“8“in˜to“Ï\answer².Ž¡�’Y7 There–{is“one“signi canš¸ãt“exception“from“the“catco�Gde“c˜hanges“that“are“done“forŽ¡�’J7 Ï\readline²:‘Òßspaces–…áand“tabs“retain“their“normal“catco�Gde“of“10,‘Òso“that“m�¸ãultipleŽ¡�’J7 spaces–¥ein“an“answ�¸ãer“will“b�Ge“reduced“to“a“single“space,‘ùiand“macros“with“normalŽ¡�’J7 space-delimited–yargumenš¸ãts“will“w˜ork“when“applied“to“the“answ˜er.‘Ý(I‘ycan't“think“ofŽ¡�’J7 an•¸ãy›·lik“ely˜scenario˜where˜category˜12˜for˜spaces˜w“ould˜b�Ge˜useful.)‘ÄîAlso,‘MOthe˜cat-Ž¡�’J7 co�Gde–œ¤of“Ï^^M“²is“set“to“9“(ignore)“so“that“an“empt�¸ãy“line|meaning“that“the“user“justŽ¡�’J7 pressed–z¤the“carriage“return/enš¸ãter“k˜ey|will“result“in“an“empt˜y“Ï\answer².‘áµIf“the“an-Ž¡�’J7 swš¸ãer–´©is“empt˜y‘ÿ*ª,‘Ì~the“giv˜en“default“string“will“b�Ge“substituted.‘�ÄThe“default“string“canŽ¡�’J7 b�Ge‘UUempt�¸ãy‘ÿ*ª.ޤï����’J7 ŸöÌ͉ff–6tŸ ff�„ ffff�ŸûÌÍ���‘³3Ï\xreadline{�¸hë`default‘¼r¸iŽ‘.C{Ï}\answerŽŽŽŽ’•i¨„ ffffŽžff‰ff–6tŽŽŽŽ¡�’J7 ²Likš¸ãe–yëÏ\readline“²but“the“answ˜er“is“read“as“executable“tok˜ens;‘Œ6the“usual“catco�Gdes“ofޤ �’J7 the–¸)T�‘þU>Ÿ'EŽ‘ãxX“sp�Gecial“cš¸ãharacters“remain“in“e ect“while“reading“the“answ˜er.‘šDA‘¸few“com-Ž¡�’J7 mon–¤mouter“things“(Ï\bye²,–ø2Ï\+²,“Ï\newif²,“Ï^^L²,“among–¤mothers)“are“neutralized“b�GeforeŽ¡�’J7 the–X Ï\read“²is“done,‘˜»but“the“user“can“still“cause“problems“bš¸ãy“en˜tering“some“otherŽ¡�’J7 outer–”{conš¸ãtrol“sequence“or“un˜balanced“braces.‘/:I‘”kdoubt“there's“an˜y“bulletpro�Gof“solu-Ž¡�’J7 tion,›œif–�öthe“tok�¸ãens“are“to“remain“executable,˜short“of“the“usual“last“resort:‘ã readingŽ¡�’J7 the–UUansw�¸ãer“using“Ï\readline²,“writing“it“to“a“ le,“then“inputting“the“ le.ŽŸï����’J7 ŸöÌ͉ff�öwŸ ff�„ ffff�ŸûÌÍ���‘³3Ï\readchar{�¸hë`default‘¼r¸iŽ‘.C{Ï}\answerŽŽŽŽ’�)«„ ffffŽžff‰ff�öwŽŽŽŽ¦�’J7 ²This–¥öis“likš¸ãe“Ï\readline“²but“it“reduces“the“answ˜er“to“its“ rst“c˜haracter.�‘7R¸hÌdefault‘òظiŽ‘,¹T²is“ei-Ž¡�’J7 ther–UUa“single“cš¸ãharacter“or“empt˜y‘ÿ*ª.ޤï����’J7 ŸöÌ͉ff�öwŸ ff�„ ffff�ŸûÌÍ���‘³3Ï\readChar{�¸hë`default‘¼r¸iŽ‘.C{Ï}\answerŽŽŽŽ’�)«„ ffffŽžff‰ff�öwŽŽŽŽ¡�’J7 ²This–UUis“likš¸ãe“Ï\readchar“²and“also“upp�Gercases“the“answ˜er.Ž¡����’J7 Ÿ÷[‰ff—2ÞŸ ‘�„ ‘ff�Ÿüé���‘³3Ï\changecase\uppercase\answerŽŽŽŽ’–f„ ‘ffŽžff‰ff—2ÞŽŽŽŽ¡�’J7 ²The–�=function“Ï\changecase“²rede nes“its“second“argumen•¸ãt,‘Œ7whic“h›�=m“ust˜b�Ge˜a˜macro,ޤ �’J7 to–™1con�¸ãtain“the“same“text“as“bšGefore,‘ª(but“upp˜ercased“or“lo•¸ãw“ercased–™1according“to“theŽ¡�’J7 rst›UUargumen•¸ãt.‘qÇTh“us˜Ï\readChar{Q}\answer˜²is˜equiv‘ÿqÇalen“t˜toŽŽŽŽŽŒ‹Aê <æ� ýÊ}ü��’Ò!DÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’üfb²5ŽŽ ‚��� þ }ü�‘ÚúÞÏ\readchar{q}\answerޤ �‘ÚúÞ\changecase\uppercase\answerŽŸ ��‘Õºâ²It–¸šmighš¸ãt“sometimes“b�Ge“desirable“to“force“lo˜w˜er“case“b�Gefore“using“a“ le“name“giv˜enŽ¡�‘Õºâb�¸ãy–UUthe“user,“for“example.ŽŸ%#��‘Õºâà1.4Ž‘ôzâChec� king‘€functionsŽŸ»—����‘ÕºâŸ÷[‰ffœrÛŸ ‘�„ ‘ff�Ÿüé���‘³3Ï\checkinteger\reply\tempcountŽŽŽŽ’›¦„ ‘ffŽžff‰ffœrÛŽŽŽŽŸ�Ø�‘Õºâ²T‘ÿ*ªo–C—read“in“and“c•¸ãhec“k–C—an“answ�¸ãer“that“is“suppšGosed“to“b˜e“an“in�¸ãteger,‘?&useŽ¡�‘ÕºâÏ\readline\reply–¾ ²and“then“apply“Ï\checkinteger“²to“the“Ï\reply²,‘ÜMsupplying“a“coun�¸ãtŽ¡�‘Õºâregister,›C"not–>•necessarily“named“Ï\tempcount²,˜wherein“Ï\checkinteger“²will“lea•¸ãv“e‘>•theŽ¡�‘Õºâv‘ÿqÇalidated–nš¸ãteger.‘^tIf“Ï\reply“²do�Ges“not“con˜tain“a“v‘ÿqÇalid“in˜teger“the“returned“v‘ÿqÇalue“willŽ¡�‘Õºâb�Ge‘UUÏ-\maxdimen².Ž© …H�‘äºâAš¸ãt–â¬the“presen˜t“time“only“decimal“digits“are“handled;‘)Xsome“v‘ÿqÇalid“T�‘þU>Ÿ'EŽ‘ãxX“n˜um˜b�GersŽ¡�‘Õºâsucš¸ãh–]Üas“Ï"AB²,“Ï`\@²,–ŸýÏ\number\prevgraf²,“or–]Üa“coun˜t“register“name,‘Ÿýwill“not“b�Ge“rec-Ž¡�‘Õºâognized–êçb�¸ãy“Ï\checkinteger².‘2|There“seems“to“bšGe“no“bulletpro˜of“w•¸ãa“y–êçto“allo�¸ãw“theseŽ¡�‘Õºâp�Gossibilities.ަ�‘äºâT‘ÿ*ªests–Y.that“hide“Ï\checkinteger“²under“the“ho•Go“d,‘‹�suc�¸ãh–Y.as“a“Ï\nonnegativeintegerŽ¡�‘Õºâ²test,‘—ºare–Šrnot“proš¸ãvided“b�Gecause“as“often“as“not“the“n˜um˜bšGer“b˜eing“prompted“for“willŽ¡�‘Õºâha•¸ãv“e–·dto“bšGe“tested“to“see“if“it“falls“inside“a“more“sp˜eci c“range,‘Öûsuc�¸ãh“as“0{255“for“an“8-Ž¡�‘Õºâbit›èÿn•¸ãum“b�Ger˜or˜1{31˜for˜a˜date,‘ êand˜it˜seems˜common˜sense˜to˜omit˜o“v“erhead˜if˜itŽ¡�‘Õºâwš¸ãould–Ä­usually“b�Ge“redundan˜t.‘¿ÏIt's“easy“enough“to“de ne“suc˜h“a“test“for“y˜ourself,‘àƒifŽ¡�‘Õºây•¸ãou›UUw“an“t˜one.ޤ�Ø����‘ÕºâŸ÷[‰ff‡rçŸ ‘�„ ‘ff�Ÿüé���‘³3Ï\checkdimen\reply\tempdimŽŽŽŽ’†¦„ ‘ffŽžff‰ff‡rçŽŽŽŽ¡�‘Õºâ²Analog–Iµof“Ï\checkinteger“²for“dimension“v›ÿqÇalues.‘mçIf“Ï\reply“²do�Ges“not“con�¸ãtain“a“v˜alidޤ �‘Õºâdimension–UUthe“v‘ÿqÇalue“returned“in“Ï\tempdim“²will“b�Ge“Ï-\maxdimen².ަ�‘äºâOnly–¸&explicit“dimensions“with“decimal“digits,‘ÐÚoptional“decimal“p�Goin�¸ãt“and“moreŽ¡�‘Õºâdecimal›Lãdigits,‘ Æfollo•¸ãw“ed˜b“y˜explicit˜units˜Ïpt˜cm˜in˜²or˜whatev“er˜are˜c“hec“k“edŽ¡�‘Õºâfor;‘�Vsome–Ðv‘ÿqÇalid“T�‘þU>Ÿ'EŽ‘ãxX“dimensions“suc�¸ãh“as“Ï\parindent²,–®ªÏ.3\baselineskip²,“orŽ¡�‘ÕºâÏ\fontdimen5\font–UU²will“not“b�Ge“recognized“b�¸ãy“Ï\checkdimen².ŽŸ$��‘ÕºâàWhat›€go•`o“d˜is˜all˜this?ŽŸIÐ�‘Õºâ²What›Ùgo•Go“d˜is˜all˜this˜stu ,‘ %practically˜sp“eaking?|y•¸ãou˜ma“y˜ask.‘[žW‘ÿ*ªell,‘ %a˜t“ypical˜ap-Ž¡�‘Õºâplication–Ô™mighš¸ãt“b�Ge“something“lik˜e:‘1iA˜t“the“bšGeginning“of“a“do˜cumenš¸ãt,‘îXprompt“in˜terac-Ž¡�‘Õºâtivš¸ãely– Kto“ nd“out“if“the“user“w˜an˜ts“to“prin˜t“on“A4“or“US‘ 9letter-size“pap�Ger,‘çor“c˜hangeŽ¡�‘Õºâthe–UUtop“or“left“margin.‘qÇSucš¸ãh“a“query“could“b�Ge“done“lik˜e“this:ŽŽ� þ }ü�’OwÏ\promptxmesj{ޤ �’OwDo–?üyou“want“to“print“on“A4“or“US“letter“paper?Ž¡�’OwEnter–?üu“or“U“for“US“letter,“anything“else“for“A4:“}Ž¡�’Ow\readChar{A}\reply–?ü%“default“=“A4Ž¡�’Ow\if–?üU\reply“\textheight=11in“\textwidth=8.5inŽ¡�’Ow\else–?ü\textheight=297mm“\textwidth=210mm“\fiŽ¡�’Ow%‘ÿðSubtract–?üspace“for“1-inch“marginsŽ¡�’Ow\addtolength{\textheight}{-2in}Ž¡�’Ow\addtolength{\textwidth}{-2in}ŽŸ�’Ow\promptxmesj{Ž¡�’OwLeft–?ümargin“setting?“[Return“=“keep“current“value,Ž¡�’Ow\the\oddsidemargin]:‘?ü}Ž¡�’Ow\readline{\the\oddsidemargin}\replyŽ¡�’Ow\checkdimen\reply{\dimen0}Ž¡�’Ow\ifdim\dimen0>-\maxdimenŽ¡�’Y÷\setlength\oddsidemargin{\dimen0}%Ž¡�’Y÷\xmesj{OK,–?üusing“new“left“margin“of“%Ž¡�’Ow\the\oddsidemargin.}Ž¡�’Ow\elseŽ¡�’Y÷\xmesj{Sorry,–?üI“don't“understand“%Ž¡�’Owthat–?üreply:“`\reply'.\Ž¡�’OwUsing–?üdefault“value:“\the\oddsidemargin.}Ž¡�’Ow\fiŽŸná�’J7 ²Although–BL�Ÿýó5�‘üff±AŽŽ‘͉²T�‘þU>Ÿ'EŽ‘ãxX's“Ï\typeout“²and“Ï\typein“²functions“can“b�Ge“used“for“this“same“task,Ž¡�’J7 they–èare“rather“more“a•¸ãwkw“ard,‘1and›èc“hec“king˜the˜margin˜v–ÿqÇalue˜for˜v“alidit•¸ãy˜w“ould˜b�GeŽ¡�’J7 quite‘UUdicult.Ž© ß��’J7 à1.5Ž’h÷ Implemen� tationŽŸ<€�’J7 ²Standard–UUpacš¸ãk‘ÿqÇage“iden˜ti cation:ŽŸ“��’J7 Å%<*2e>ޤ �’J7 \NeedsT–ÿ:«eXF“ormat{LaT“eX2e}Ž¡�’J7 \Pro•¾9videsP“ac“k‘ÿ|rage{dialog}[1994/11/08‘Tv0.9y]Ž¡�’J7 %ަ��’J7 à1.6Ž’h÷ PreliminariesŽŸ…�’J7 Å%<*2e>Ž¡�’J7 \RequireP•¾9ac“k‘ÿ|rage{grabhedr}Ž¡�’J7 %ŽŽŽŽŽŒ‹]k <æ� ýÊ}ü��’Ò!DÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’üfb²6ŽŽ ‚�ŸðO]�� þ.Ÿ�‘äºâIf–\Ïgrabhedr.sty“²is“not“already“loaded,‘�µload“it“no�¸ãw.‘…áThe“Ï\trap.input“²func-Ž© �‘Õºâtion–UUis“explained“in“Ïgrabhedr.doc².ŽŸéð�‘ÕºâÅ%<*209>ޤ �‘Õºâ\csname‘Ttrap.input\endcsnameŽ¡�‘Õºâ\input–Tgrabhedr.st�¾9y“\relaxŽ¡�‘Õºâ\ lev•¾9ersiondate{dialog.st“y}{0.9y}{1994/11/08}%Ž¡�‘Õºâ%ŽŸéð�‘äºâ²The– 'functions“Ï\localcatcodes“²and“Ï\restorecatcodes“²are“de ned“inަ�‘ÕºâÏgrabhedr.sty².‘õ‰W‘ÿ*ªe–Ö–use“them“to“sa•¸ãv“e–Ö–and“restore“catcošGdes“of“an�¸ãy“sp˜ecial“c�¸ãhar-ަ�‘Õºâacters–xneeded“in“this“ le“whose“currenš¸ãt“catco�Gdes“migh˜t“not“b�Ge“what“w˜e“w˜an˜t“themަ�‘Õºâto–ÞÜbšGe.‘]Sa�¸ãving“and“restoring“catco˜de“of“at-sign“Ï@“²makš¸ães“this“ le“w˜ork“equally“w˜ellަ�‘Õºâas–ûZa“L�Ÿýó5�‘üff±AŽŽ‘͉²T�‘þU>Ÿ'EŽ‘ãxX“do�Gcumen•¸ãtst“yle–ûZoption“or“as“a“simple“input“ le“in“other“con�¸ãtexts.‘c×Theަ�‘Õºâdouble–+$quote“cš¸ãharacter“Ï"“²migh˜t“b�Ge“activ˜e“for“German“and“other“languages.‘ó5Sa˜v-ަ�‘Õºâing–mêand“restoring“tilde“Ï~²,›´hash“Ï#²,˜caret“Ï^²,˜and“left“quote“Ï`“²catco�Gdes“is“normallyަ�‘Õºâredundanš¸ãt–ëebut“reduces“the“n˜um˜b�Ger“of“assumptions“w˜e“m˜ust“rely“on.‘3ø(The“follo˜w-ަ�‘Õºâing–Úcatco�Gdes“are“assumed:‘{'Ï\“²0,›û1Ï{“²1,˜Ï}“²2,˜Ï%“²14,˜Ïa²{Ïz“A²{ÏZ‘Ùã²11,˜Ï0²{Ï9“.“-“²12.‘ÿ×Also“noteަ�‘Õºâthat–UUÏ\endlinechar“²is“assumed“to“ha•¸ãv“e–UUa“non-n�¸ãull“v‘ÿqÇalue.)ŽŸéð�‘ÕºâÅ%%–TThe“line“break“is“signi can�¾9t“here:Ž¡�‘Õºâ\lo•AÇcalcatco“des{\@{11}\‘T{10}\Ž¡�‘Õºâ{5}\~{13}\"{12}\#{6}\^{7}\`{12}}ŽŸ!¯N��‘Õºâà1.7Ž‘ôzâDe nitionsŽŸ…‘�‘Õºâ²F‘ÿ*ªor–ýÝdeactiv‘ÿqÇating“c�¸ãharacters“with“spšGecial“catco˜des“during“Ï\readline“²w�¸ãe“use,‘[insteadަ�‘Õºâof–1‘Ï\dospecials²,‘h a“more“bulletprošGof“(alb˜eit“slo•¸ãw“er)›1‘com“bination˜of˜Ï\otherchars²,ަ�‘ÕºâÏ\controlchars²,‘˜and–мÏ\highchars“²that“co•¸ãv“ers–мall“c�¸ãharacters“in“the“range“0{255“ex-ަ�‘Õºâcept–Ááletters“and“digits.‘·lHandling“the“cš¸ãharacters“ab�Go˜v˜e“127“triples“the“o˜v˜erheadަ�‘Õºâdone–jUfor“eac�¸ãh“read“op�Geration“or“message“de nition“but“seems“mandatory“for“maxi-ަ�‘Õºâm�¸ãum‘UUrobustness.��Ÿü^ÿ±2ŽŽŽŸ Þ³�‘äºâÏ\otherchars–D²includes“the“thirtš¸ãy-three“nonalphan˜umeric“visible“c˜haractersަ�‘Õºâ(counš¸ãting–}space“as“visible).‘£>It“is“in˜tended“as“an“executable“list“lik˜e“Ï\dospecialsަ�‘Õºâ²but,›*£as–÷an“exercise“in“memory“conserv‘ÿqÇation,˜it“is“constructed“without“the“Ï\do²s.‘_ýF‘ÿ*ªorަ�‘Õºâthe–ÕÖusual“application“of“c�¸ãhanging“catcošGdes,‘õöthe“list“can“still“b˜e“executed“nicely“asަ�‘Õºâsho•¸ãwn›‰b�Gelo“w.‘ðcAlso,‘Šif˜w“e˜arrange˜to˜mak“e˜sure˜that˜eac“h˜c“haracter˜tok“en˜gets˜cat-ަ�‘Õºâegory–—J12,‘çÇit's“not“necessary“to“use“conš¸ãtrol“sym˜b�Gols“suc˜h“as“Ï\%“²in“place“of“thoseަ�‘Õºâfew–Áásp�Gecial“cš¸ãharacters“that“w˜ould“otherwise“b�Ge“dicult“to“place“inside“of“a“de ni-ަ�‘Õºâtion.‘jèThis›@·a•¸ãv“oids˜a˜problem˜that˜w“ould˜otherwise˜arise˜if˜w“e˜included˜Ï\+˜²in˜the˜listަ�‘Õºâand– tried“to“pro�Gcess“the“list“with“a“t�¸ãypical“de nition“of“Ïdo²:‘Ó2Ï\+“²is“`outer'“in“plainަ�‘ÕºâT�‘þU>Ÿ'EŽ‘ãxX–lÇand“w�¸ãould“cause“an“error“message“when“Ï\do“²attempted“to“read“it“as“an“argu-ަ�‘Õºâmenš¸ãt.‘r](As–U‡a“matter“of“fact“the“catco�Gde“c˜hanges“b�Gelo˜w“sho˜w“a“di eren˜t“w˜a˜y“aroundŽŽ� þ.Ÿ�’J7 that–…ùproblem,‘¯rbut“a“list“of“category-12“cš¸ãharacter“tok˜ens“is“a“fun“thing“to“ha˜v˜e“aroundޤ �’J7 an•¸ãyw“a“y‘ÿ*ª.)Ž©ú,�’J7 Å\b�AÇegingroupŽŸú,�’J7 ²First–ÈFwš¸ãe“start“a“group“to“lo�Gcalize“Ï\catcode“²c˜hanges.‘Ê›Then“w˜e“c˜hange“all“relev‘ÿqÇan˜tŽ¡�’J7 catcošGdes– 5to“12“except“for“bac�¸ãkslash,‘\do\,\do\.Ž¡�’J7 \do\/\do\?\do\|12\relaxŽŸú,�’J7 ²T‘ÿ*ªo–ahandle“bacš¸ãkslash“and“braces,‘¤w˜e“de ne“Ï\\²,–¤Ï\{²,“and–aÏ\}“²to“pro�Gduce“the“corre-ޤ �’J7 sp�Gonding–¬çcategory-12“cš¸ãharacter“tok˜ens.‘x|Setting“Ï\escapechar“²to“¸²1“means“thatŽ¡�’J7 Ï\string–`D²will“omit“the“leading“bacš¸ãkslash“that“it“w˜ould“otherwise“pro�Gduce“when“ap-Ž¡�’J7 plied–UUto“a“con�¸ãtrol“sequence.Ž© }�’J7 Å\escap�AÇec�¾9har‘T-1ޤ �’J7 \edef\\{\string\\}Ž¡�’J7 \edef\{{\string\{}\edef\}{\string\}}ŽŸ}�’J7 ²Space–‡nand“pšGercen�¸ãt“are“done“last.‘Then,‘“õwith“almost“all“the“sp˜ecial“cš¸ãharacters“no˜wŽŸ �’J7 category–UU12,“it's“rather“easy“to“de ne“Ï\otherchars².ަ�’J7 Å\catco•AÇde`\‘T=12\catco“de`\%=12Ž¡�’J7 \xdef\otherc�¾9harsŽ¡�’J7 {‘T!"#$%&'()*+,-./:;<=>?[\\]^_`\{|\}~}Ž¡�’J7 \endgroup‘T%‘+*˜^‘j¤^‘*¨^ŽŸwB�’J7 Ï\controlchars–´Ž²is“another“list“for“the“conš¸ãtrol“c˜haracters“ë[asci�8ãi“²0{31“and“127.‘�rTheޤ �’J7 construction–yof“this“list“is“similar“to“the“construction“of“Ï\otherchars².‘ÝW‘ÿ*ªe“need“toŽ¡�’J7 turn–!Qo “Ï\endlinechar“²bšGecause“the“catco˜de“of“Ï^^M“²is“going“to“b˜e“c�¸ãhanged.‘`qThe“Ï^^LŽ¡�’J7 ²inside–Éthe“Ï\gdef“²is“not“a“problem“(as“it“mighš¸ãt“ha˜v˜e“b�Geen,‘åýdue“to“the“usual“outer-Ž¡�’J7 ness–UUof“Ï^^L²)“bšGecause“the“catco˜de“is“c�¸ãhanged“from“13“to“12“b˜efore“that“p˜oin�¸ãt.ŽŸú,�’J7 Å\b�AÇegingroupޤ �’J7 \endlinec�¾9har–T=“-1Ž¡�’J7 \def\do{12‘T\catco�AÇde`}Ž¡�’J7 \catco�AÇde`\^^@\do\^^A\do\^^B\do\^^CŽ¡�’J7 \do\^^D\do\^^E\do\^^F\do\^^G\do\^^H\do\^^IŽŽŽ‘ÕºâŸæf‰ff%ûÇŸ J=����‘ "5Ÿý-:º2ŽŽŽ‘LÜÀIf–ÕXyšÃŽou“are“using“ëLdialog.sty“Àfunctions“on“a“slo˜w“computer,“y˜ou“migh˜t“w˜an˜t“to“try“setting“ëL\highchars“À=“empt˜y“to“see“if“that“helps“the“sp�Ÿ'EŽ‘ãxX.)‘ëýIf“the“assignmen�¸ãt“is“a“de nition“(Ï\def²,–]–Ï\edef²,“Ï\gdef²,“Ï\xdef²)Ž¡�‘Õºâit–—Qis“allo•¸ãw“ed–—Qto“takš¸ãe“argumen˜ts“in“the“normal“T�‘þU>Ÿ'EŽ‘ãxX“w˜a˜y‘ÿ*ª.‘7¼Pre xes“suc˜h“as“Ï\global²,Ž¡�‘ÕºâÏ\long²,–UUor“Ï\outer“²mš¸ãust“go“inside“the“ rst“argumen˜t“rather“than“b�Gefore“Ï\actively².Ž¡�‘äºâUsage:ŽŸ)·s����‘ÕºâŸÞÌ͉ffÏöSŸ%J�„%Jff�Ÿüé��Ÿè�‘³3Ï\actively\def\?{�¸hë`replacementŽ�‘Bãktext‘¼r¸iŽ‘]ƒ`Ï}Ž¡�‘³3\actively\def\%#1#2{�¸hë`replacementŽ�‘Bãktext‘¼r¸iŽ‘]ƒ`Ï}Ž¡�‘³3\actively{\global\let}\^^@=\spaceŽŽŽŽ’Ï)‡„%JffŽžff‰ffÏöSŽŽŽŽŸ,�‘Õºâ²One– åplace“where“this“function“can“bšGe“put“to“go˜o˜d“use“is“in“making“Ï^^M“²activ�¸ãe“in“or-Ž¡�‘Õºâder–ÎÂto“get“sp�Gecial“action“at“the“end“of“eacš¸ãh“line“of“input.‘ÞThe“usual“w˜a˜y“of“goingŽŽ� þ }ü�’J7 abšGout–UUthis“w�¸ãould“b˜e“to“writeޤ¯_�’OwÏ\def\par{something}\obeylinesŽ¡�’J7 ²whicš¸ãh–øis“a“puzzling“construction“to“the“T�‘þU>Ÿ'EŽ‘ãxX“no˜vice“who“do�Gesn't“kno˜w“whatޤ �’J7 Ï\obeylines–É´²došGes“with“Ï\par².‘ÎãThe“same“e ect“could“b˜e“gotten“a“little“more“trans-Ž¡�’J7 paren�¸ãtly‘UUwithޤ¯_�’OwÏ\actively\def\^^M{something}Ž¡�’Y7 ²In–the“de nition“of“Ï\actively“²w�¸ãe“use“the“unique“prop�Gerties“of“Ï\lowercaseޤ �’J7 ²to–çKcreate“an“activš¸ãe“c˜haracter“with“the“righ˜t“c˜haracter“co�Gde,‘KÈo˜v˜erlapping“with“aŽ¡�’J7 Ï\begingroup–UU\endgroup“²structure“that“lošGcalizes“the“necessary“lc-co˜de“c�¸ãhange.Ž© W¯�’J7 Å\def\activ•¾9ely#1#2{\catco�AÇde`#2\activ“eޤ �’Pa´\b•AÇegingroup‘T\lcco“de`\~=`#2\relaxŽ¡�’Pa´\lo•¾9w“ercase{\endgroup#1~}}ŽŸ�’J7 ²The–¸ÂÏ\mesjsetup“²function“starts“a“group“to“lošGcalize“catco˜de“c�¸ãhanges.‘=–The“group“willޤ �’J7 b�Ge–Å)closed“ev•¸ãen“tually›Å)b“y˜a˜separate˜function˜that˜do�Ges˜the˜actual˜sending˜or˜storesŽ¡�’J7 the–UUmessage“text“for“later“retriev‘ÿqÇal.Ž¡�’Y7 W‘ÿ*ªe›Ùjw•¸ãan“t˜to˜c“hange˜the˜catco�Gde˜of˜eac“h˜c“haracter˜in˜the˜three˜lists˜Ï\otherchars²,Ž¡�’J7 Ï\controlchars²,›Oãand–N†Ï\highchars“²to“12.‘o‚After“giving“Ï\do“²a“recursiv�¸ãe“de nition,˜w�¸ãeŽ¡�’J7 apply– šit“to“eacš¸ãh“of“the“three“lists,‘Àadding“a“suitable“elemen˜t“at“the“end“of“the“list“toŽ¡�’J7 makš¸ãe–ž£the“recursion“stop“there.‘4áThis“allo˜ws“lea˜ving“out“the“Ï\do“²tok˜ens“from“the“c˜har-Ž¡�’J7 acter–UUlists,“without“incurring“the“cost“of“an“if“test“at“eac�¸ãh“recursion“step.ަ�’J7 Å\def\mesjsetup{\b�AÇegingroup‘T\coun�¾9t@=12ޤ �’Pa´\def\do##1{\catco�AÇde`##1\coun�¾9t@‘T\do}%ŽŸW¯�’J7 ²The–UUabbreviation“Ï\xp@“²=“Ï\expandafter“²is“from“Ïgrabhedr.sty².ަ�’Pa´Å\xp@\do\otherc•¾9hars{a11‘T\@gobblet“w“o}%Ž¡�’Pa´\xp@\do\con•¾9trolc“hars{a11‘T\@gobblet“w“o}%Ž¡�’Pa´\xp@\do\highc•¾9hars{a11‘T\@gobblet“w“o}%ŽŸW¯�’J7 ²Makš¸ãe–UUthe“tab“c˜haracter“pro�Gduce“eigh˜t“spaces:ަ�’Pa´Å\activ�¾9ely\edef\^^I{‘T\space\space\spaceŽ¡�’VŒ\\space\space\space\space}%ŽŸW¯�’J7 ²The›â£con•¸ãv“enien“t˜treatmen“t˜of˜newlines˜in˜the˜argumen“t˜of˜Ï\mesj˜²(ev“ery˜line˜breakޤ �’J7 pro�Gduces–Q¿a“line“break“on“screen)“is“ac•¸ãhiev“ed›Q¿b“y˜making˜the˜Ï^^M˜²c“haracter˜activ“eŽ¡�’J7 and–Îsde ning“it“to“pro�Gduce“a“category-12“Ï^^J“²c�¸ãharacter.‘Ý"Although“for“Ï\mesj“²itŽ¡�’J7 w•¸ãould›�Ìha“v“e˜suced˜to˜mak“e˜Ï^^M˜²category˜12˜and˜lo�Gcally˜set˜Ï\newlinechar˜²=˜Ï^^MŽ¡�’J7 ²while–MÛsending“the“message,‘OZit“turns“out“to“b�Ge“useful“for“other“functions“to“ha•¸ãv“e‘MÛtheŽ¡�’J7 Ï^^M–�ñ²cš¸ãharacter“activ˜e,‘œso“that“it“can“bšGe“remapp˜ed“to“an“arbitrary“function“for“han-Ž¡�’J7 dling–&Wnew“lines“(e.g.,‘Z—pšGerhaps“adding“extra“spaces“at“the“b˜eginning“of“eac�¸ãh“line).Ž¡�’J7 And–:gif“Ï\mesj“²treats“Ï^^M“²the“same,‘s«w�¸ãe“can“arrange“for“it“to“share“the“setup“rou-Ž¡�’J7 tines–UUneeded“for“the“other“functions.ަ�’Pa´Å\endlinec•¾9har=`\^^M\activ“ely\let\^^M=\relaxŽŸ �’Pa´\catco•AÇde`\{=1›T\catco“de`\}=2˜}ŽŽŽŽŽŒ‹ˆv <æ� ýÊ}ü��’Ò!DÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’üfb²8ŽŽ ‚��� þ }ü�‘ÕºâIn–§‘Ï\sendmesj“²wš¸ãe“go“to“a“little“extra“trouble“to“mak˜e“sure“Ï^^M“²pro�Gduces“a“newlineޤ �‘Õºâcš¸ãharacter,‘]Ëno–(çmatter“what“the“v‘ÿqÇalue“of“Ï\newlinechar“²migh˜t“b�Ge“in“the“surround-Ž¡�‘Õºâing›Œ#en•¸ãvironmen“t.‘0The˜imp�Gending˜Ï\endgroup˜²will˜restore˜Ï\newlinechar˜²to˜its˜pre-Ž¡�‘Õºâvious–m©v‘ÿqÇalue.‘ºÃOne“reason“for“using“Ï^^J“²(instead“of,–³¾saš¸ãy‘ÿ*ª,“Ï^^M–m©²directly)“is“to“allo˜wŽ¡�‘Õºâe.g.‘5Ï\mesj{xxx^^Jxxxx}–ãϲto“b�Ge“written“inside“a“de nition,‘mas“is“sometimes“con•¸ãv“e-Ž¡�‘Õºânien•¸ãt.‘qÇThis›UUw“ould˜b•Ge˜dicult˜with˜Ï^^M˜²instead˜of˜Ï^^J˜²b“ecause˜of˜catco“des.Ž©:³�‘ÕºâÅ\def\sendmesj{\newlinec�¾9har`\^^J%ޤ �‘ÛåŠ\activ�¾9ely\def\^^M{^^J}%Ž¡�‘ÛåŠ\immediate\write\sixt@@n{\mesjtext}\endgroup}ŽŸI`�‘Õºâ²Giv�¸ãen–�the“suppšGort“functions“de ned“ab˜o•¸ãv“e,‘Ûthe–�de nition“of“Ï\mesj“²is“easy:‘áZUseޤ �‘ÕºâÏ\mesjsetup–>Ò²to“clear“all“spšGecial“catco˜des,‘CRthen“set“up“Ï\sendmesj“²to“b˜e“triggered“b�¸ãyŽ¡�‘Õºâthe–Ÿˆnext“assignmenš¸ãt,‘Ãäthen“read“the“follo˜wing“balanced-braces“group“in˜to“Ï\mesjtext².Ž¡�‘ÕºâAs–Ç`so�Gon“as“the“de nition“is“completed,›ãÄT�‘þU>Ÿ'EŽ‘ãxX“will“execute“Ï\sendmesj²,˜whic�¸ãh“will“sendŽ¡�‘Õºâthe–+htext“and“close“the“group“that“w�¸ãas“started“in“Ï\mesjsetup“²to“lo�Gcalize“the“cat-Ž¡�‘Õºâco�Gde‘UUc�¸ãhanges.ަ�‘ÕºâÅ\def\mesj{\mesjsetup‘T\afterassignmen�¾9t\sendmesjŽŸ �‘ÛåŠ\def\mesjtext}ŽŸI`�‘Õºâ²The–x—Ï\sendprompt“²function“is“just“lik�¸ãe“Ï\sendmesj“²except“that“it“uses“Ï\message“²in-Ž¡�‘Õºâstead–×gof“Ï\write²,›ð—as“migh�¸ãt“b�Ge“desired“when“prompting“for“user“input,˜so“that“the“on-Ž¡�‘Õºâscreen–ZÁcursor“staš¸ãys“on“the“same“line“as“the“prompt“instead“of“hopping“do˜wn“to“theŽ¡�‘Õºâb�Geginning–«cof“the“next“line.‘9!In“order“for“newlines“to“wš¸ãork“with“Ï\message“²w˜e“m˜ust“useŽ¡�‘Õºâa–�}visible“cš¸ãharacter“instead“of“Ï^^J².‘@When“ev˜ery˜one“has“T�‘þU>Ÿ'EŽ‘ãxX“v˜ersion“3.1415“or“laterŽ¡�‘Õºâthis–Hwill“no“longer“b�Ge“true.‘mXThe“cš¸ãhoice“of“Ï!“²migh˜t“b�Ge“construed“(if“y˜ou“wish)“as“ed-Ž¡�‘Õºâitorial–UUcommen�¸ãt“that“Ï!“²should“not“b�Ge“shouted“at“the“user“in“a“prompt.ަ�‘ÕºâÅ\def\sendprompt{%ޤ �‘ÛåŠ\newlinec•¾9har`\!\relax‘T\activ“ely\def\^^M{!}%Ž¡�‘ÛåŠ\message{\mesjtext}\endgroup}ŽŸI`�‘Õºâ²This–UUfunction“is“lik�¸ãe“Ï\mesj“²but“uses“Ï\sendprompt“²instead“of“Ï\sendmesj².ަ�‘ÕºâÅ\def\promptmesj{\mesjsetupŽ¡�‘ÛåŠ\afterassignmen�¾9t\sendprompt‘T\def\mesjtext}Ž©I`�‘Õºâ²Arg–Ó‰Ï#1“²of“Ï\storemesj“²is“the“conš¸ãtrol“sequence“under“whic˜h“the“message“text“is“toŽŸ �‘Õºâb�Ge‘UUstored.ŽŸ([�‘ÕºâÅ\def\storemesj#1{\mesjsetupŽ¡�‘ÛåŠ\catco�AÇde`\#=6–T%“to“alloš¾9w“argumen˜ts“if“neededŽ¡�‘ÛåŠ\afterassignmen�¾9t\endgroupŽ¡�‘ÛåŠ\long\gdef#1}ަ�‘Õºâ²While–&wÏ\storemesj\foo{...}“²is“more“or“less“the“same“as“Ï\def\foo{...}“²with“sp�Ge-ŽŸ �‘Õºâcial–xcatcošGde“c�¸ãhanges,‘‰AÏ\fmesj\foo{...}“²corresp˜onds“to“Ï\def\foo{\mesj{...}}²,ŽŽ� þ }ü�’J7 that–is,‘1after“Ï\fmesj\foo“²the“function“Ï\foo“²can“b�Ge“executed“directly“to“send“theޤ �’J7 message.‘PµThš¸ãus–ôúÏ\storemesj“²is“t˜ypically“used“for“storing“pieces“of“messages,‘ãwhileŽ¡�’J7 Ï\fmesj–UU²is“used“for“storing“en�¸ãtire“messages.ŽŸ �ï�’Y7 T‘ÿ*ªo–ÙÅread“the“parameter“text“Ï#2²,‘ò|w�¸ãe“use“the“p�Geculiar“Ï#{“²feature“of“T�‘þU>Ÿ'EŽ‘ãxX“to“read“ev-Ž¡�’J7 erything–UUup“to“the“op�Gening“brace.Ž©[t�’J7 Å\def\fmesj#1#2#{\mesjsetupŽŸ �’Pa´\catco�AÇde`\#=6–T%“restore“to“normalŽŸ[t�’J7 ²The–¼«parameter“text“Ï#2“²mš¸ãust“b�Ge“stored“in“a“tok˜en“register“rather“than“a“macroŽ¡�’J7 to›,3a•¸ãv“oid˜problems˜with˜Ï#˜²c“haracters.‘öaThe˜Ï\long˜²pre x˜is˜just˜to˜admit˜the˜(un-Ž¡�’J7 lik•¸ãely)›“:p�Gossibilit“y˜of˜using˜Ï\fmesj˜²to˜de ne˜something˜suc“h˜as˜an˜error˜messageŽ¡�’J7 sa�¸ãying–;ª`Y‘ÿ*ªou“can't“use“Ï#1“²here'“where“one“of“the“p�Gossibilities“for“Ï#1“²is“Ï\string\par².ަ�’Pa´Å\toks@{\long\gdef#1#2}%ŽŸ[t�’J7 ²De ne–ØÜÏ\@tempa“²to“put“together“the“ rst“t•¸ãw“o›ØÜargumen“ts˜and˜[pseudo]argumen“t˜Ï#3Ž¡�’J7 ²and–UUmak�¸ãe“the“de nition“of“Ï#1².ަ�’Pa´Å\def\@tempa{%ޤ �’VŒ\\edef\@tempa{%Ž¡�’\·\the\toks@{%ŽŸ[t�’J7 ²The–UUabbreviation“Ï\nx@“²=“Ï\noexpand“²is“from“Ïgrabhedr.sty².ަ�’\·Å\b�AÇegingroup\def\nx@\mesjtext{\the\toks2‘T}%Ž¡�’bá¬\nx@\sendmesj}%Ž¡�’VŒ\}%Ž¡�’VŒ\\@tempaŽ¡�’VŒ\\endgroup–T%“T‘ÿ:«urn“o “the“\mesjsetup“catco�AÇdesŽ¡�’Pa´}%Ž¡�’Pa´\afterassignmen�¾9t\@tempaŽ¡�’Pa´\toks2=}ŽŸw¼�’J7 Ï\xmesjsetup–E|²is“likš¸ãe“Ï\mesjsetup“²except“it“prepares“to“allo˜w“con˜trol“sequence“to-ޤ �’J7 kš¸ãens–¨-and“normal“commen˜ts“in“the“message“text.‘jPF‘ÿ*ªor“T�‘þU>Ÿ'EŽ‘ãxXnicians'“con˜v˜enience“cer-Ž¡�’J7 tain–UUother“features“are“thro�¸ãwn“in.ŽŸ �ï�’Y7 Here,›:­unlik�¸ãe–Ùœthe“setup“for“Ï\xreadline²,˜I‘Ù7don't“b�Gother“to“remo•¸ãv“e–Ùœthe“outer-Ž¡�’J7 ness–Ãof“Ï\bye²,–ÞmÏ\newif²,“etc.,“b�Gecause–ÃI‘Âæpresume“the“argumen�¸ãts“of“Ï\xmesj²,‘ÞmÏ\fxmesj²,Ž¡�’J7 Ï\storexmesj²,–¼pÏ\fxmenu²,“etc.––6are“more“likš¸ãely“to“b�Ge“written“b˜y“a“T�‘þU>Ÿ'EŽ‘ãxXnician“than“b˜y“anŽ¡�’J7 a•¸ãv“erage–xqend“user,‘¤Ÿwhereas“Ï\xreadline“²is“designed“to“handle“arbitrary“input“from“ar-Ž¡�’J7 bitrary‘UUusers.ŽŸùc�’J7 Å\def\xmesjsetup{\mesjsetupŽŸùc�’J7 ²Throš¸ãw–vßin“pseudo“braces“just“in“case“w˜e“are“inside“an“Ï\halign“²with“Ï\\“²let“equal“toŽ¡�’J7 Ï\cr–UU²at“the“time“when“Ï\xmesjsetup“²is“called.‘qÇ(As“migh�¸ãt“happ�Gen“in“¸A�‘þU>Ÿ'MŽ‘ ‹S‘€²-T�‘þU>Ÿ'EŽ‘ãxX.)ަ�’Pa´Å\i alse{\ ŽŸ �’Pa´\catco•AÇde`\\=0‘T\catco“de`\%=14ŽŽŽŽŽŒ‹ ž™ <æ� ýÊ}ü��’Ò!DÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’üfb²9ŽŽ ‚��� þ }ü�‘ÕºâDe ne‘XÏ\%–:\\“\{“\}“\&–,²to“prošGduce“the“corresp˜onding“single“c�¸ãharacters,‘category“12.Ž© �‘ÕºâThe–UUÏ\lowercase“²tricš¸ãk“here“allo˜ws“these“de nitions“to“b�Ge“nonglobal.ŽŸ ¤«�‘ÛåŠÅ\b•AÇegingroup‘T\lcco“de`\0=`\\\lcco“de`\1=`\{%ޤ �‘ÛåŠ\lcco•AÇde`\2=`\}\lcco“de`\3=`\%%Ž¡�‘ÛåŠ\lo•¾9w“ercase{\endgroup‘T\def\\{0}\def\{{1}%Ž¡�‘â2\def\}{2}\def\%{3}}%Ž¡�‘ÛåŠ\i alse}\ Ž¡�‘ÛåŠ\edef\&{\string‘T&}%ŽŸ¤«�‘Õºâ²Let–QjÏ&“=“\noexpand“²for“expansion“conš¸ãtrol“inside“the“argumen˜t“text;‘R¸let“activ˜e“Ï^^M“=ަ�‘Õºâ\relax–UU²so“that“newlines“will“remain“inert“during“the“expansion.ŽŸ ¤«�‘ÛåŠÅ\activ�¾9ely\let\&=\no�AÇexpandŽ¡�‘ÛåŠ\activ�¾9ely\let\^^M=\relaxޤ¤«�‘Õºâ²De ne–º-Ï\.“²to“bšGe“a“no˜op,‘Ócfor“terminating“a“conš¸ãtrol“w˜ord“when“it“is“follo˜w˜ed“b˜y“let-ަ�‘Õºâters–UUand“no“space“is“w•¸ãan“ted.ŽŸ ¤«�‘ÛåŠÅ\def\.{}%Ž¡�‘Õºâ²Supp�Gort–difor“use“of“Ï\xmesj“²inside“a“de nition“replacemenš¸ãt“text“or“macro“argumen˜t:ަ�‘Õºâconš¸ãtrol-space–ŽnÏ\ “²=“Ï\space²,‘œ´tilde“Ï~“²prin˜ts“as“itself,›œ´Ï\ “²(i.e.,˜a“lone“bac�¸ãkslash“at“theަ�‘Õºâend–CNof“a“line)“will“pro�Gduce“a“newline,›Féalso“Ï\ ²,˜while“ nally“Ï\par“=“²blank“line“trans-ަ�‘Õºâlates–UUto“t•¸ãw“o‘UUnewlines.ŽŸ ¤«�‘ÛåŠÅ\def\–T{“}\edef~{\string“~}%Ž¡�‘Õºâ²De ne–RyÏ\ “²to“pro�Gduce“an“activš¸ãe“Ï^^M“²c˜haracter,‘S whic˜h“(w˜e“hopšGe)“will“b˜e“suitably“de-ަ�‘Õºâ ned–UUto“pro�Gduce“a“newline“or“whatev�¸ãer.Ž© ¤«�‘ÛåŠÅ\b•AÇegingroup‘T\lcco“de`\~=`\^^M%ޤ �‘â2\lo•¾9w“ercase{\endgroup‘T\def\^^M{~}}%Ž¡�‘ÛåŠ\let\^^J\^^M‘T\def\par{\^^M\^^M}%Ž¡�‘Õºâ}ŽŸî�‘ÕºâÏ\xmesj–UU²uses“Ï\xmesjsetup“²and“Ï\edef².ަ�‘ÕºâÅ\def\xmesj{\xmesjsetup‘T\afterassignmen�¾9t\sendmesjŽ¡�‘ÛåŠ\edef\mesjtext}ŽŸî�‘ÕºâÏ\promptxmesj–UU²is“analogous“to“Ï\promptmesj²,“but“with“expansion.ަ�‘ÕºâÅ\def\promptxmesj{\xmesjsetupŽ¡�‘ÛåŠ\afterassignmen�¾9t\sendprompt‘T\edef\mesjtext}ŽŸî�‘Õºâ²And–îHÏ\storexmesj“²is“likš¸ãe“Ï\storemesj²,‘…with“expansion.‘<¡Since“w˜e“allo˜w“argumen˜tsޤ �‘Õºâfor–(7the“function“b�Geing“de ned,‘1=wš¸ãe“also“m˜ust“de ne“Ï\#“²to“pro�Gduce“a“single“category-Ž¡�‘Õºâ12–UUÏ#“²cš¸ãharacter“so“that“there“will“b�Ge“a“w˜a˜y“to“prin˜t“Ï#“²in“the“message“text.ަ�‘ÕºâÅ\def\storexmesj#1#2#{\xmesjsetupޤ �‘ÛåŠ\catco�AÇde`\#=6–T%“to“alloš¾9w“argumen˜ts“if“neededŽ¡�‘ÛåŠ\edef\#{\string##}%Ž¡�‘ÛåŠ\afterassignmen�¾9t\endgroupŽ¡�‘ÛåŠ\long\xdef#1#2}ŽŽ� þ }ü�’J7 ²And–UUÏ\fxmesj“²is“the“expansiv�¸ãe“analog“of“Ï\fmesj².Ž©mw�’J7 Å\def\fxmesj#1#2#{\xmesjsetupޤ �’Pa´\catco�AÇde`\#=6–T%“restore“to“normalŽ¡�’Pa´\edef\#{\string##}%Ž¡�’Pa´\toks@{\long\xdef#1#2}%Ž¡�’Pa´\def\@tempa{%Ž¡�’VŒ\\edef\@tempa{%Ž¡�’\·\the\toks@{\b�AÇegingroupŽ¡�’\·\def\nx@\nx@\nx@\mesjtext{\the\toks\t�¾9w@}%Ž¡�’\·\nx@\nx@\nx@\sendmesj}}%Ž¡�’VŒ\\@tempa–T%“execute“the“constructed“xdefŽ¡�’VŒ\\endgroup–T%“restore“normal“catco�AÇdesŽ¡�’Pa´}%Ž¡�’Pa´\afterassignmen�¾9t\@tempaŽ¡�’Pa´\toks\t�¾9w@=}ŽŸ"ì��’J7 à1.8Ž’h÷ Reading‘€functionsŽŸôÕ�’J7 ²The–ÖmÏ\readline“²function“gets“one“line“of“input“from“the“user.‘õArgumen�¸ãts“are:‘s÷Ï#1ޤ �’J7 ²default–-»to“bšGe“used“if“the“user“resp˜onse“is“empt�¸ãy“(i.e.,‘5§if“the“user“just“pressed“the“re-Ž¡�’J7 turn/en•¸ãter›UUk“ey),˜Ï#2˜²macro˜to˜receiv“e˜the˜input.ŽŸ‡ó�’J7 Å\def\readline#1#2{%ޤ �’Pa´\b�AÇegingroup–T\coun�¾9t@“12“%Ž¡�’Pa´\def\do##1{\catco�AÇde`##1\coun�¾9t@‘T\do}%Ž¡�’Pa´\xp@\do\otherc•¾9hars{a11‘T\@gobblet“w“o}%Ž¡�’Pa´\xp@\do\con•¾9trolc“hars{a11‘T\@gobblet“w“o}%Ž¡�’Pa´\xp@\do\highc•¾9hars{a11‘T\@gobblet“w“o}%ŽŸ‡ó�’J7 ²Mak�¸ãe–UUspaces“and“tabs“normal“instead“of“category“12.ަ�’Pa´Å\catcošAÇde`\–T=10“\catco˜de`\^^I=10“%Ž¡�’Pa´\catco�AÇde`\^^M=9–T%“ignoreޤmw�’J7 ²Reset–UUend-of-line“c�¸ãhar“to“normal,“just“in“case.ަ�’Pa´Å\endlinec�¾9har`\^^MŽ¡�’J7 ²W‘ÿ*ªe–fgo“to“a“little“trouble“to“a•¸ãv“oid–fÏ\gdef²-ing“Ï#2²,‘•òin“order“to“prev•¸ãen“t›fsa“v“e˜stac“k˜buildupޤ �’J7 if–&Öthe“user“of“Ï\readline“²carries“on“una•¸ãw“are–&Ödoing“lo�Gcal“rede nitions“of“Ï#2“²after“theŽ¡�’J7 initial‘UUread.ަ�’Pa´Å\read\m@ne‘Tto#2%ޤ �’Pa´\edef#2{\def\nx@#2{#2}}%Ž¡�’Pa´\xp@\endgroup‘T#2%Ž¡�’Pa´\ifx\@empt�¾9y#2\def#2{#1}\ Ž¡�’J7 }ŽŽŽŽŽŒ‹ ´› <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²10ŽŽ ‚��� þ }ü�‘ÕºâÏ\xreadline–�à²is“likš¸ãe“Ï\readline“²except“that“it“lea˜v˜es“almost“all“catco�Gdes“unc˜hanged“soޤ �‘Õºâthat–Ùóthe“return“v‘ÿqÇalue“is“executable“tokš¸ãens“instead“of“strictly“c˜haracter“tok˜ens“of“cat-Ž¡�‘Õºâegory–UU11“or“12.ޤ b�‘ÕºâÅ\def\xreadline#1#2{%Ž© �‘ÛåŠ\b�AÇegingroupŽŸb�‘Õºâ²Render–UUsome“outer“con�¸ãtrol“sequences“inno�Gcuous.Ž¡�‘â2Å\xp@\let\csname‘Tb•¾9y“e\endcsname\relaxަ�‘â2\xp@\let\csname‘Tnewif\endcsname\relaxަ�‘â2\xp@\let\csname‘Tnew•¾9coun“t\endcsname\relaxަ�‘â2\xp@\let\csname‘Tnewdimen\endcsname\relaxަ�‘â2\xp@\let\csname‘Tnewskip\endcsname\relaxަ�‘â2\xp@\let\csname‘Tnewm�¾9uskip\endcsname\relaxަ�‘â2\xp@\let\csname‘Tnewtoks\endcsname\relaxަ�‘â2\xp@\let\csname‘Tnewb�AÇo�¾9x\endcsname\relaxަ�‘â2\xp@\let\csname‘Tnewinsert\endcsname\relaxަ�‘â2\xp@\let\csname‘T+\endcsname\relaxަ�‘â2\activ�¾9ely\let\^^L\relaxަ�‘ÛåŠ\catco�AÇde`\^^M=9–T%“ignoreަ�‘ÛåŠ\endlinec�¾9har`\^^M%–Treset“to“normalަ�‘ÛåŠ\read\m@ne‘Tto#2%ަ�‘ÛåŠ\toks@\xp@{#2}%ަ�‘ÛåŠ\edef\@tempa{\def\nx@#2{\the\toks@}}%ަ�‘ÛåŠ\xp@\endgroup‘T\@tempaަ�‘ÛåŠ\ifx\@empt�¾9y#2\def#2{#1}\ ަ�‘Õºâ}ŽŸ&�‘ÕºâÏ\readchar–UU²reduces“the“user“resp�Gonse“to“a“single“c�¸ãharacter.Ž¡�‘ÕºâÅ\def\readc�¾9har#1#2{%ަ�‘ÛåŠ\readline{#1}#2%ŽŸb�‘Õºâ²If–f4the“user's“respšGonse“and“the“default“resp˜onse“are“b˜oth“empt•¸ãy‘ÿ*ª,‘jlw“e–f4need“somethingŽŸ �‘Õºâafter–UUÏ#1“²to“kš¸ãeep“Ï\@car“²from“running“a˜w˜a˜y‘ÿ*ª,“so“w˜e“add“an“empt˜y“pair“of“braces.Ž¡�‘ÛåŠÅ\edef#2{\xp@\@car#2#1{}\@nil}%ަ�‘Õºâ}ŽŸ&�‘ÕºâÏ\readChar–fÖ²reduces“the“user“respšGonse“to“a“single“upp˜ercase“c�¸ãharacter.‘¦J(This“is“use-ޤ �‘Õºâful–UUto“simplify“testing“the“resp�Gonse“later“with“Ï\if².)ŽŸÄ�‘ÕºâÅ\def\readChar#1#2{%ަ�‘ÛåŠ\readline{#1}#2%ަ�‘ÛåŠ\c�¾9hangecase\upp�AÇercase#2%ŽŸÄ�‘Õºâ²Reduce–8†Ï#2“²to“its“ rst“cš¸ãharacter,‘>Ior“the“ rst“c˜haracter“of“Ï#1²,‘>Iif“Ï#2“²is“empt˜y‘ÿ*ª.‘h-The“ex-Ž¡�‘Õºâtra–ßbraces“Ï{}“²are“to“prev•¸ãen“t–ßa“runa•¸ãw“a“y›ßargumen“t˜error˜from˜Ï\@car˜²if˜Ï#2˜²and˜Ï#1˜²areŽ¡�‘Õºâb�Goth‘UUempt�¸ãy‘ÿ*ª.ŽŸ b�‘ÛåŠÅ\edef#2{\xp@\@car‘T#2#1{}\@nil}%ަ�‘Õºâ}ŽŽ� þ }ü�’J7 ²The–ðÉfunction“Ï\changecase“²upp�Gercases“or“lo•¸ãw“ercases–ðÉthe“replacemen�¸ãt“text“of“its“sec-ޤ �’J7 ond›�ùargumen•¸ãt,‘�"whic“h˜m“ust˜b�Ge˜a˜macro.‘÷³The˜ rst˜argumen“t˜should˜b�Ge˜Ï\uppercaseŽ¡�’J7 ²or‘UUÏ\lowercase².Ž©q6�’J7 Å\def\c�¾9hangecase#1#2{\@casetoks\xp@{#2}%ŽŸ �’Pa´\edef#2{#1{\def\nx@#2{\the\@casetoks}}}#2}ŽŸÍØ�’J7 ²W‘ÿ*ªe–ü­allošGcate“a“tok�¸ãen“register“just“for“the“use“of“Ï\changecase“²b˜ecause“it“migh�¸ãt“b˜eŽ¡�’J7 used–ñ at“a“loš¸ãw“lev˜el“in˜ternally“where“w˜e“don't“w˜an˜t“to“in˜terfere“with“other“uses“ofŽ¡�’J7 the–UUscratcš¸ãh“tok˜en“registers“0{9.ަ�’J7 Å\newtoks\@casetoksŽŸÍØ�’Y7 ²A‘¬0common–¬Ftask“in“reading“user“input“is“to“vš¸ãerify‘ÿ*ª,‘Âwhen“an“answ˜er“of“a“certainŽ¡�’J7 kind–P²w�¸ãas“requested,›Q that“the“resp�Gonse“has“indeed“the“desired“form|for“example,˜ifŽ¡�’J7 a–±ãnonnegativš¸ãe“in˜teger“is“required“for“subsequen˜t“prošGcessing,‘Éit“b˜eho˜o•¸ãv“es–±ãus“to“v�¸ãer-Ž¡�’J7 ify–y�that“wš¸ãe“ha˜v˜e“a“nonnegativ˜e“in˜teger“in“hand“b�Gefore“doing“an˜ything“that“migh˜t“leadŽ¡�’J7 to›¯‰incon•¸ãv“enien“t˜error˜messages.‘€bHo“w“ev“er,‘Æit's˜not˜easy˜to˜decide˜ho“w˜b�Gest˜to˜han-Ž¡�’J7 dle–UUsucš¸ãh“v˜eri cation.‘qÇOne“p�Gossibilit˜y“migh˜t“b�Ge“to“ha˜v˜e“a“functionޤfì�’OwÏ\readnonnegativeinteger\fooŽ¡�’J7 ²to–¤1do“all“the“wš¸ãork“of“going“out“and“fetc˜hing“a“n˜um˜b�Ger“from“the“user“and“lea˜v-ޤ �’J7 ing–7Áit“in“the“macro“Ï\foo².‘ Another“p�Gossibilitš¸ãy“w˜ould“bšGe“to“read“the“resp˜onse“us-Ž¡�’J7 ing–”Ï\readline“²and“then“apply“a“separate“function“that“can“b�Ge“used“in“com�¸ãbinationŽ¡�’J7 with–UUÏ\if²,“for“exampleŽ©fì�’Y÷Ï\readline{}\replyŽ¡�’Y÷\if\validnumber\reply–?ü...“\else“...“\fiަ�’J7 ²F‘ÿ*ªor–=ômaximš¸ãum“ exibilit˜y‘ÿ*ª,‘xa“sligh˜tly“lo˜w˜er-lev˜el“approac˜h“is“c˜hosen“here.‘+¤The“tar-Ž¡�’J7 get–UUsyn�¸ãtax“isަ�’Y÷Ï\readline{}\replyŽ¡�’Y÷\checkinteger\reply\tempcountަ�’J7 ²where–"·Ï\tempcount“²will“bšGe“set“to“Ï-\maxdimen“²if“Ï\reply“²do˜es“Ìnot‘�²con�¸ãtain“a“v‘ÿqÇalid“in-Ž¡�’J7 teger.‘F¨(Negativ•¸ãe›Ó÷in“tegers˜are˜allo“w“ed,‘í×as˜long˜as˜they˜are˜greater˜than˜Ï-\maxdimen².)Ž¡�’J7 Then–£Ïthe“function“that“calls“Ï\checkinteger“²is“free“to“makš¸ãe“additional“c˜hec˜ks“on“theŽ¡�’J7 range–¢Wof“the“reply“and“giv�¸ãe“error“messages“tailored“to“the“circumstances.‘XÍAnd“theŽ¡�’J7 handling–gPof“an“emptš¸ãy“Ï\reply“²can“b�Ge“arbitrarily“customized,‘kÏsomething“that“w˜ouldŽ¡�’J7 tend–UUto“bšGe“incon•¸ãv“enien“t–UUfor“the“ rst“metho˜d“men�¸ãtioned.ŽŸ 3v�’Y7 The–fÊ rst“and“second“approac�¸ãhes“can“b�Ge“built“on“top“of“the“third“if“desired,‘k'e.g.Ž¡�’J7 (for–UUthe“second“approac�¸ãh)ަ�’OwÏ\def\validnumber#1{TT\fiŽ¡�’Y÷\checkinteger#1\tempcount%Ž¡�’Y÷\ifnum\tempcount>-\maxdimen‘?ü}ŽŽŽŽŽŒ‹ Å€ <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²11ŽŽ ‚��� þ }ü�‘ÕºâThe–‰Úcurious“ÏTT\fi...\ifnum“²construction“is“from“ÏTeXhax“²1989,‘–üno.“20“and“no.“38ޤ �‘Õºâ(a–UUsuggestion“of“D.“E.“Knš¸ãuth“in“reply“to“a“query“b˜y“S.“v˜on“Bec˜h˜tolsheim).ŽŸP•�‘ÕºâThe–E’argumenš¸ãts“of“Ï\checkinteger²'s“are:‘iåÏ#2²,‘H¹a“coun˜t“register“to“hold“the“result;‘JÓÏ#1²,Ž¡�‘Õºâa–UUmacro“holding“zero“or“more“arbitrary“c�¸ãharacters“of“category“11“or“12.ŽŸ3“�‘ÕºâÅ\def\c•¾9hec“kin“teger#1#2{\let\scansign@\@empt“yޤ �‘ÛåŠ\def\scanresult@{#2}%Ž¡�‘ÛåŠ\xp@\scanin�¾9t#1x\endscan}ŽŸ@x�‘Õºâ²T‘ÿ*ªo–áJv‘ÿqÇalidate“a“n•¸ãum“b�Ger,‘Gthe–áJfunction“Ï\scanint“²mš¸ãust“ rst“scan“a˜w˜a˜y“leading“Ï+“²or“Ï-ޤ �‘Õºâ²signs–£â(kš¸ãeeping“trac˜k“in“Ï\scansign@²),‘·…then“lo�Gok“at“the“ rst“tok˜en“after“that:‘áif“it'sŽ¡�‘Õºâa›rùdigit,–ºa ne,“scan˜that˜digit˜and˜an•¸ãy˜succeeding˜digits˜in“to˜the˜giv“en˜coun“t˜reg-Ž¡�‘Õºâister–g÷(Ï\scanresult@²),‘¬Ÿending“with“Ï\endscan“²to“get“rid“of“anš¸ãy“follo˜wing“garbageŽ¡�‘Õºâtokš¸ãens–UUthat“migh˜t“just“p�Gossibly“sho˜w“up.Ž© �‘äºâTš¸ãypical–oŒusage“of“Ï\scanint“²includes“initializing“Ï\scansign@“²to“empt˜y‘ÿ*ª,‘vas“in“theŽ¡�‘Õºâde nition–UUof“Ï\checkinteger².ŽŸ*tž����‘ÕºâŸß[‰ffœrÛŸ$‘�„$‘ff�Ÿüé��Ÿè�‘³3Ï\let\scansign@\@emptyŽ¡�‘³3\def\scanresult@{\tempcount}%Ž¡�‘³3\xp@\scanint\reply‘?üx\endscanŽŽŽŽ’›¦„$‘ffŽžff‰ffœrÛŽŽŽŽŸ0Z�‘Õºâ²Assumption:‘Î+Ï\reply–ƒ‡²is“either“emptš¸ãy“or“con˜tains“only“category“11“or“12“c˜harac-Ž¡�‘Õºâters–ÿ[(whicš¸ãh“it“will“if“y˜ou“used“Ï\readline²!).‘oØIf“a“separate“c˜hec˜k“is“done“earlier“toŽ¡�‘Õºâtrap– the“case“where“Ï\reply“²is“emptš¸ãy|for“example,‘:ôb˜y“using“a“nonempt˜y“defaultŽ¡�‘Õºâfor–UUÏ\readline²|then“the“Ïx“²bšGefore“Ï\endscan“²is“sup˜er uous.ަ�‘äºâArg–PÏ#1“²=“next“c�¸ãharacter“from“the“string“b�Geing“tested.‘pThe“test“whether“Ï#1“²is“aŽ¡�‘Õºâdecimal–H¥digit“is“similar“in“spirit“to“the“test“Ï\if!#1!“²to“see“if“an“argumenš¸ãt“is“empt˜yŽ¡�‘Õºâ(ÌThe‘“çT�‘þKß'EŽ‘Í-Xb–ÿ}'o“ok²,–UUApp�Gendix“D,“p.“376).Ž©#u�‘ÕºâÅ\def\scanin�¾9t#1{%ŽŸ �‘ÛåŠ\ifo�AÇdd–T0#11“%ŽŸ#u�‘Õºâ²Is–‘Ï#1“²a“decimal“digit?‘Ð{If“so“read“all“digits“in�¸ãto“Ï\scanresult@“²with“the“sign“pre-Ž¡�‘Õºâ x.ަ�‘â2Å\def\@tempa{\afterassignmen�¾9t\endscanޤ �‘è:Ú\scanresult@=\scansign@#1}%Ž¡�‘ÛåŠ\elseŽ¡�‘â2\if‘T-#1\relaxŽŸ#u�‘Õºâ²Here–UUwš¸ãe“ ip op“the“sign;“w˜atc˜h“closely‘ÿ*ª.ަ�‘è:ÚÅ\edef\scansign@{%Ž¡�‘îe‚\ifx\@empt�¾9y\scansign@‘T-\ }%Ž¡�‘è:Ú\def\@tempa{\scanin�¾9t}%Ž¡�‘â2\elseŽŸ#u�‘Õºâ²A–UUplus“sign“can“just“b�Ge“ignored.ަ�‘è:ÚÅ\if‘T+#1\relaxŽŽ� þ }ü�’bá¬\def\@tempa{\scanin�¾9t}%ޤ �’\·\else–T%“not“a“v‘ÿ|ralid“n•¾9um“b�AÇerŽ¡�’bá¬\def\@tempa{%Ž¡�’i T\scanresult@=-\maxdimen\endscan}%Ž¡�’Pa´\ \ \ Ž¡�’Pa´\@tempaŽ¡�’J7 }ޤÚµ�’J7 ²The–³ˆÏ\endscan“²function“just“gobbles“anš¸ãy“remaining“garbage.‘Œ_It“uses“its“o˜wn“nameŽ© �’J7 as–UUthe“argumen�¸ãt“delimiter.ŽŸ ž<�’J7 Å\def\endscan#1\endscan{}Ž¡�’J7 Ï\dimenfirstpart²,›a–àGcoun�¸ãt“register,˜receiv�¸ães“the“digits,˜if“an�¸ãy‘ÿ*ª,˜preceding“the“deci-ަ�’J7 mal–Òæp�Goinš¸ãt.‘FMÏ\dimentoks²,‘ìüa“tok˜en“register,‘ìüreceiv˜es“an˜y“digits“after“the“decimal“p�Goin˜t.ŽŸ ž<�’J7 Å\new•¾9coun“t\dimen rstpartŽŸ �’J7 \newtoks\dimen�¾9toksŽ¡�’J7 Ï\scandimen–6i²is“similar“to“Ï\scanint“²but“has“to“call“some“auxiliary“functions“to“scanަ�’J7 the–&üv‘ÿqÇarious“sub•Gcomp“onenš¸ãts–&üof“a“dimension“(leading“digits,‘0Adecimal“p�Goin˜t,‘0Afractionalަ�’J7 part,–íÊand›Óçunits,“with˜optional˜Ïtrue²,“in˜addition˜to˜the˜sign).‘F£The˜minim�¸ãum˜require-ަ�’J7 menš¸ãts–ʇof“T�‘þU>Ÿ'EŽ‘ãxX's“syn˜tax“for“dimensions“are“a“digit“or“decimal“p�Goin˜t“Ï+“²the“units;‘ allަ�’J7 the–UUother“comp�Gonen�¸ãts“are“optional“(ÌThe‘“çT�‘þKß'EŽ‘Í-Xb–ÿ}'o“ok²,–UUExercise“10.3,“p.“58).ަ�’Y7 When–bsscanning“for“the“digits“of“a“fractional“part,‘¥ºwš¸ãe“can't“thro˜w“a˜w˜a˜y“lead-ަ�’J7 ing–ðzeros;‘-therefore“wš¸ãe“don't“read“the“fractional“part“in˜to“a“coun˜t“register“as“w˜e“didަ�’J7 for–ÌÑthe“digits“bšGefore“the“decimal“p˜oinš¸ãt;‘�instead“w˜e“read“the“digits“one“b˜y“one“andަ�’J7 store–UUthem“in“Ï\dimentoks².ަ�’Y7 The–Ÿ'EŽ‘ãxX“as“decimal“p�Goin˜t“c˜haracters).ŽŸŸ'EŽ‘ãxX's“parameter-matc�¸ãhing“abilities“to“a“sp�Gecial“string“that“willŽ¡�’J7 yield–UUa“b•Go“olean–UUv›ÿqÇalue“of“true“if“and“only“if“the“giv�¸ãen“string“is“a“v˜alid“T�‘þU>Ÿ'EŽ‘ãxX“unit.ަ�’J7 Å\def\scan�¾9unitsb#1#2{%ޤ �’Pa´\def\@tempa##1#1#2##2##3\@nil{##2}%Ž¡�’Pa´\def\@tempb##1{T\@tempaŽ¡�’VŒ\p�AÇcTptTcmTccT–ÿ:«emT“exTinTmmTddTspT##1F\@nil}%ŽŸ™‘�’J7 ²F‘ÿ*ªorce› lo•¸ãw“ercase˜just˜in˜case˜the˜units˜w“ere˜en“tered˜with˜upp�Gercase˜letters˜(acceptedŽŸ �’J7 bš¸ãy–UUT�‘þU>Ÿ'EŽ‘ãxX,“so“w˜e“had“bšGetter“accept“upp˜ercase“also).ަ�’Pa´Å\lo•¾9w“ercase{%Ž¡�’Pa´\if\@tempb{#1#2}%Ž¡�’Pa´}%Ž¡�’Sw\scanresult@=\scansign@Ž¡�’Y¡°\n•¾9um“b�AÇer\dimen rstpart.\the\dimen“toksŽŽŽŽŽŒ‹ íS <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²13ŽŽ ‚��� þ }ü�‘å%†Å\dimen�¾9true@#1#2\relaxޤ �‘ÛåŠ\elseŽ¡�‘â2\scanresult@=-\maxdimenŽ¡�‘ÛåŠ\ ŽŸÙå�‘Õºâ²Call–UUÏ\endscan“²to“gobble“garbage“tokš¸ãens,“if“an˜y‘ÿ*ª.Ž©Ùå�‘ÛåŠÅ\endscanŽ¡�‘Õºâ}ŽŸŒ,�‘Õºâ²Argumenš¸ãt–ˆìÏ#2“²m˜ust“bšGe“a“dimen“register;‘¢·Ï#1“²is“exp˜ected“to“b˜e“a“macro“holding“zeroŽŸ �‘Õºâor–UUmore“arbitrary“c�¸ãharacters“of“category“11“or“12.ަ�‘ÕºâÅ\def\c•¾9hec“kdimen#1#2{%Ž¡�‘ÛåŠ\let\scansign@\@empt�¾9y‘T\def\scanresult@{#2}%Ž¡�‘ÛåŠ\let\dimen•¾9true@\@empt“yŽ¡�‘ÛåŠ\dimen rstpart\z@‘T\dimen�¾9toks{}%Ž¡�‘ÛåŠ\xp@\scandimen#1xx\endscanŽ¡�‘Õºâ}ŽŸŒ,�‘äºâ²Finish‘UUup.ަ�‘ÕºâÅ\restorecatco�AÇdesŽ¡�‘Õºâ\endinputŽŸ›ë�‘ÕºâàP� art‘€2ŽŸc �‘ÕºâMen� u‘€functions:‘ámenus.styŽŸM³��‘Õºâà2.1Ž‘ôzâF‘þàunction‘€descriptionsŽŸ_#����‘պ⟯[‰fffö�ŸS-€�„S-€ff�Ÿýwz��Ÿ¸�‘³3Ï\fmenu\foobar{ޤ ��‘ó0¸hë`preliminaryŽ�‘IÖ›text‘¼r¸iŽŽ¡�‘³3Ï}{Ž¡��‘ó0¸hë`menuŽ�‘%°lines‘¼r¸iŽŽ¡�‘³3Ï}{Ž¡��‘ó0¸hë`followingŽ�‘?V¡text‘¼r¸iŽŽ¡�‘³3Ï}ŽŽŽŽ‘f)ÄS-€ffŽžff‰fffö�ŽŽŽŽŸ)!�‘Õºâ²De nes–µ¤Ï\foobar“²as“a“function“that“puts“the“preliminary“text,‘͸the“men�¸ãu“lines“(listޤ �‘Õºâof–UUc�¸ãhoices),“and“the“after“text“on“screen.‘qÇNormal“usage:Ž©Æ�‘ÚúÞÏ\foobar‘9¿Ô%–?üprint“the“menu“on“screenŽ¡�‘ÚúÞ\readline{}\reply–?ü%“read“the“answerަ�‘Õºâ²(See–Éthe“description“of“Ï\readline“²in“Ïdialog.doc².)‘C+In“the“v‘ÿqÇarious“text“parts“all“sp�Ge-Ž¡�‘Õºâcial–[#cš¸ãharacters“ha˜v˜e“category“12“except“for“braces,‘\—as“with“Ï\mesj².‘ƒ2Note“the“recom-Ž¡�‘Õºâmended–}Yplacemen�¸ãt“of“the“braces:‘ÁÎno“closing“brace“falls“at“the“end“of“a“line,‘‡YexceptŽŽ� þ }ü�’J7 the–]‡v�¸ãery“last“one.‘Š^Because“of“the“spšGecial“catco˜des“in“e ect“when“reading“the“ -ޤ �’J7 nal–|ûthree“argumenš¸ãts,‘Æäa“Ï^^M“²or“Ï%“²b�Get˜w˜een“argumen˜ts“w˜ould“b�Ge“read“as“an“activ˜eŽ¡�’J7 cš¸ãharacter–(„or“category-12“c˜haracter“resp�Gectiv˜ely‘ÿ*ª,‘1zinstead“of“b�Geing“ignored.‘b×But“actu-Ž¡�’J7 ally‘ÿ*ª,›Ñ@after–°:some“rather“dicult“programming,˜I‘°managed“to“mak�¸ãe“it“p�Gossible“to“writeŽ¡�’J7 just–ÏÌab�Gout“anš¸ãything“(except“brace“c˜haracters)“b�Get˜w˜een“the“argumen˜ts“and“ha˜v˜e“itŽ¡�’J7 b�Ge–% ignored,‘Xøso“the“recommended“st�¸ãyle“is“not“mandatory‘ÿ*ª.‘àèThe“ rst“and“last“new-Ž¡�’J7 line–±of“eacš¸ãh“argumen˜t“are“stripp�Ged“o “an˜yw˜a˜y“in“order“to“pro�Gduce“consisten˜t“cleanŽ¡�’J7 connections–UUwith“Ï\menuprefix“²etc.;“see“b�Gelo�¸ãw.ŽŸ X�’Y7 Menš¸ãu–•]functions“created“b˜y“Ï\fmenu“²are“allo˜w˜ed“optionally“to“ha˜v˜e“argumen˜ts,‘»Âlik˜eŽ¡�’J7 functions–- created“with“Ï\fmesj“²(from“Ïdialog.sty²),‘5so“that“pieces“of“text“can“b�Ge“in-Ž¡�’J7 serted–_Žat“the“time“of“use.‘�sThis“makš¸ães“it“p�Gossible“for“sev˜eral“similar“men˜us“to“shareŽ¡�’J7 the–UUsame“menš¸ãu“function“if“there“are“only“minor“v‘ÿqÇariations“b�Get˜w˜een“them.ŽŸ:����’J7 Ÿë[‰ff‚2韻º�„»ºff�Ÿüé@��Ÿô�‘³3Ï\menuprefix,‘?ü\menusuffixŽ¡�‘³3\inmenuA,‘?ü\inmenuBŽŽŽŽ’�f„»ºffŽžff‰ff‚2éŽŽŽŽ©�’J7 ²The–ržtext“Ï\menuprefix“²will“bšGe“added“at“the“b˜eginning“of“eacš¸ãh“men˜u;‘�CÏ\menusuffixŽ¡�’J7 ²will–M•bšGe“added“at“the“end.‘o2The“text“Ï\inmenuA“²and“Ï\inmenuB“²will“b˜e“added“b˜et•¸ãw“eenŽ¡�’J7 the–�r rst“and“second,‘ïyresp�Gectivš¸ãely“second“and“third“parts“of“the“men˜u;‘A�their“de-Ž¡�’J7 fault–¾lv‘ÿqÇalues“prošGduce“a“blank“line“on“screen.‘­ (But“Ï\inmenuA“²will“b˜e“omitted“if“theŽ¡�’J7 rst–Supart“is“emptš¸ãy‘ÿ*ª,‘’ýand“Ï\inmenuB“²will“b�Ge“omitted“if“the“last“part“is“empt˜y–ÿ*ª.)‘l(T“oŽ¡�’J7 c•¸ãhange›UUan“y˜of˜these˜texts,˜use˜Ï\storemesj˜²or˜Ï\storexmesj².‘qÇF‘ÿ*ªor˜example:ŽŸ° �’J7 Ï\storemesj\menuprefix{*********–?üMENU“**********}ŽŸ¸ ����’J7 Ÿ÷[‰ff=óŸ ‘�„ ‘ff�Ÿüé���‘³3\menupromptŽŽŽŽ‘=&E„ ‘ffŽžff‰ff=óŽŽŽŽ¦�’J7 ²F‘ÿ*ªurthermore,‘1the–òfunction“Ï\menuprompt“²is“called“at“the“vš¸ãery“end“of“the“men˜u,‘1soŽ¡�’J7 that–L¸for“example“a“standard“prompt“suc�¸ãh“as“ÏEnter–?ýa“number:–L¸²could“b�Ge“applied“atŽ¡�’J7 the–UUend“of“all“menš¸ãus,“if“desired.‘qÇT‘ÿ*ªo“c˜hange“Ï\menuprompt²,“use“Ï\fmesj“²or“Ï\fxmesj².ŽŸLW����’J7 Ÿë[‰ffŒ²ãŸ‘�„‘ff�Ÿüé��Ÿô�‘³3Ï\menuline,‘?ü\endmenulineŽ¡�‘³3\menutopline,‘?ü\menubotlineŽŽŽŽ’‹æ„‘ffŽžff‰ffŒ²ãŽŽŽŽ¦�’J7 ²Eacš¸ãh–Oùline“in“the“middle“argumen˜t“of“Ï\fmenu“²(the“list“of“c˜hoices)“is“em˜b�Gedded“inŽ¡�’J7 a– (statemen�¸ãt“Ï\menuline...\endmenuline².‘™@The“default“de nition“of“Ï\menuline“²isŽ¡�’J7 to–uadd“t•¸ãw“o–uspaces“at“the“b�Geginning“and“a“newline“at“the“end.‘ÑLines“in“the“topŽ¡�’J7 or–%Sb�Gottom“part“of“the“menš¸ãu“are“em˜b�Gedded“in“Ï\menutopline...\endmenuline“²orŽ¡�’J7 Ï\menubotline...\endmenuline–¸²resp�Gectiv�¸ãely‘ÿ*ª.‘]“(Notice“that“all“three“share“the“sameŽ¡�’J7 ending–·delimiter;‘ëÛif“di erenš¸ãt“actions“are“w˜an˜ted“at“the“end“of“a“top“or“b�Gottom“line“asŽ¡�’J7 opp�Gosed–Èzto“a“middle“menš¸ãu“line,‘ä¦they“m˜ust“b�Ge“obtained“b˜y“de ning“Ï\menutopline“²orŽ¡�’J7 Ï\menubotline–[²to“read“the“enš¸ãtire“line“as“an“argumen˜t“and“p�Gerform“the“desired“pro-Ž¡�’J7 cessing.)ŽŸ X�’Y7 An–;enclosing“b�Goš¸ãx“for“a“men˜u“can“b�Ge“obtained“b˜y“de ning“Ï\menuline“²and“its“rel-Ž¡�’J7 ativš¸ães–UUappropriately“and“using“Ï\fxmenu“²(see“b�Gelo˜w).ŽŽŽŽŽŒ‹úÿ <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²14ŽŽ ‚��� þR‰\����‘պ⟯[‰fffö�ŸS-€�„S-€ff�Ÿýwz��Ÿ¸�‘³3Ï\fxmenu\foobar{ޤ ��‘ó0¸hë`preliminaryŽ�‘IÖ›text‘¼r¸iŽŽ¡�‘³3Ï}{Ž¡��‘ó0¸hë`menuŽ�‘%°lines‘¼r¸iŽŽ¡�‘³3Ï}{Ž¡��‘ó0¸hë`followingŽ�‘?V¡text‘¼r¸iŽŽ¡�‘³3Ï}ŽŽŽŽ‘f)ÄS-€ffŽžff‰fffö�ŽŽŽŽŸÛ �‘Õºâ²Similar–; to“Ï\fmenu“²but“with“full“expansion“in“eac�¸ãh“part“of“the“text,‘@^as“with“Ï\xmesj².ŽŸ I�‘äºâT‘ÿ*ªo–·7get“an“enclosing“b�Goš¸ãx“for“a“men˜u,‘ϰwrite“Ï\.“²at“the“end“of“eac˜h“men˜u“line“(toޤ �‘Õºâprotect–ªïthe“preceding“spaces“from“T�‘þU>Ÿ'EŽ‘ãxX's“prop�Gensitš¸ãy“to“remo˜v˜e“c˜haracter“32“at“theŽ¡�‘Õºâend–ÿ»of“a“line,›*Uregardless“of“its“catco�Gde),˜and“then“mak�¸ãe“sure“that“Ï\menuline“²andŽ¡�‘ÕºâÏ\endmenuline–UU²put“in“the“appropriate“b�Go•¸ãx-dra“wing›UUc“haracters˜on˜either˜side.‘qÇI.e.:Ž©’�‘ÚúÞÏ\fxmenu\foobar{Ž¡�‘ÚúÞFirst‘?üline’·¿t\.Ž¡�‘ÚúÞSecond‘?üline’²x\.Ž¡�‘ÚúÞ}{Ž¡�‘ÚúÞThird‘?üline’·¿t\.Ž¡�‘ÚúÞ...Ž¡�‘ÚúÞ}{Ž¡�‘ÚúÞLast‘?üline’¼ÿp\.Ž¡�‘ÚúÞ}ަ�‘Õºâ²With–7®the“Ï/o“²option“of“emT�‘þU>Ÿ'EŽ‘ãxX,‘=œyš¸ãou“can“use“the“b�Go˜x-dra˜wing“c˜haracters“in“the“stan-Ž¡�‘Õºâdard–UUPC“DOS“c�¸ãharacter“set.ŽŸXæk����‘պ⟯[‰ffrróŸS-€�„S-€ff�Ÿýwz��Ÿ¸�‘³3Ï\nmenu\Alph\foobar#1{Ž¡��‘ó0¸hë`preliminaryŽ�‘IÖ›text‘¼r¸iŽŽ¡�‘³3Ï}{Ž¡��‘ó0¸hë`menuŽ�‘%°lines‘¼r¸iŽŽ¡�‘³3Ï}{Ž¡��‘ó0¸hë`followingŽ�‘?V¡text‘¼r¸iŽŽ¡�‘³3Ï}ŽŽŽŽ‘q¦'„S-€ffŽžff‰ffrróŽŽŽŽŸÛ �‘Õºâ\nmenu–βand“Ï\nxmenu“²are“likš¸ãe“Ï\fmenu²,‘éÏ\fxmenu“²except“that“they“automatically“n˜um-Ž¡�‘Õºâb�Ger–Ï‚eacš¸ãh“line“of“the“middle“part“of“the“men˜u.‘E,(This“allo˜ws“men˜u“c˜hoices“to“b�Ge“addedŽ¡�‘Õºâor–‹-deleted“without“tedious“ren•¸ãum“b�Gering.)‘PThe–‹- rst“argumenš¸ãt“indicates“the“t˜yp�Ge“ofŽ¡�‘Õºân•¸ãum“bšGers–B#to“b˜e“used:‘KbÏ\alph²,–}VÏ\Alph²,“Ï\arabic²,“Ï\roman²,“Ï\Roman–B#²(follo�¸ãwing“L�Ÿýó5�‘üff±AŽŽ‘͉²T�‘þU>Ÿ'EŽ‘ãxX).Ž¡�‘ÕºâÌThese–“çar›ÿ}'e“not“yet“implemente˜d.ŽŸ I�‘äºâ²The–“†function“Ï\menunumber“²(taking“one“argumenš¸ãt)“is“applied“to“eac˜h“automati-Ž¡�‘Õºâcally–UUgenerated“n•¸ãum“b�Ger.‘qÇThe–UUdefault“v‘ÿqÇalue“is“to“add“brac•¸ãk“ets–UUand“a“space“after:ަ�‘ÚúÞÏ\def\menunumber#1{[#1]‘?ü}ަ�‘Õºâ²but–))bš¸ãy“rede ning“Ï\menunumber“²y˜ou“can“add“paren˜theses“or“extra“spaces“or“whatŽŽ� þ }ü�’J7 ha•¸ãv“e›ÿy“ou˜around˜eac“h˜n“um“b�Ger.‘UIn“ternally˜a˜line˜of˜an˜auton“um“b�Gered˜men“u˜is˜storedޤ �’J7 asŽ©Œ„�’OwÏ\menuline\menunumber{5}Text–?ütext“...\endmenulineŽŸ_J����’J7 Ÿ÷[‰ffb²üŸ ‘�„ ‘ff�Ÿüé���‘³3\optionexec\answerŽŽŽŽ‘aæ0„ ‘ffŽžff‰ffb²üŽŽŽŽŸÒÆ�’J7 ²This–µ�is“a“companion“function“for“Ï\readChar“²and“the“menš¸ãu“functions:‘2=it“c˜hec˜ks“toŽ¡�’J7 see–Yµif“the“answš¸ãer“is“equal“to“an˜y“one“of“the“c˜haracters“Ï?“Q“q“X“x²,‘šÌand“if“so“exe-Ž¡�’J7 cutes–UUÏ\moption?“²or“Ï\moptionQ“²or“Ï\moptionX“²resp�Gectiv�¸ãely‘ÿ*ª,“otherwise“executesަ�’OwÏ\csname–?ümoption\curmenu“C\endcsnameަ�’J7 ²where–IÏC“²means“the“cš¸ãharacter“that“w˜as“read“and“Ï\curmenu“²is“a“string“iden˜tifyingŽ¡�’J7 the–currenš¸ãt“lo�Gcation“in“the“men˜u“system.‘Z(Ï\optionexec“²pushes“and“p�Gops“Ï\curmenuŽ¡�’J7 ²when–-going“b�Get•¸ãw“een›-men“us,‘%5to˜k“eep˜it˜up˜to˜date.)‘]ºIf˜this˜con“trol˜sequence˜is˜unde-Ž¡�’J7 ned,›ÜÖÏ\optionexec–¾¶²giv�¸ães“a“generic“\Sorry‘ÿ*ª,˜I‘¾�don't“understand"“message“and“rep�GeatsŽ¡�’J7 the–UUcurrenš¸ãt“men˜u.ŽŸ FB�’Y7 Thš¸ãus–Äžthe“ma‘Ž8jor“w˜ork“in˜v˜olv˜ed“in“making“a“men˜u“system“is“to“de ne“theŽ¡�’J7 men�¸ãu–hescreens“using“Ï\fmenu²,–í(Ï\fxmenu²,“and–hethen“de ne“corresp�Gonding“functionsŽ¡�’J7 Ï\moptionXXX–˲that“displaš¸ãy“one“of“the“men˜u“screens,‘Q(read“a“men˜u“c˜hoice,‘Q(and“callŽ¡�’J7 Ï\optionexec–UU²to“branc�¸ãh“to“the“next“action.ޤÒÆ����’J7 Ÿ÷[‰ffÐò¼Ÿ ‘�„ ‘ff�Ÿüé���‘³3Ï\specialhelp\answer{Substitute‘?ümessage}ŽŽŽŽ’Ð%ð„ ‘ffŽžff‰ffÐò¼ŽŽŽŽ¡�’J7 ²As–3�it“turns“out,‘:Nit“is“sometimes“desirable“to“substitute“some“other“message“in“placeޤ �’J7 of–„ythe“generic“\Sorry‘ÿ*ª,‘�BI‘„mdon't“understand"“message“givš¸ãen“b˜y“Ï\optionexec².‘ÿ3F‘ÿ*ªor“in-Ž¡�’J7 stance,‘WŸ'EŽ‘ãxX“from“inš¸ãtruding“on“y˜our“carefully“designed“men˜uŽ¡�’J7 screens,‘ ²if–ø Ï\input“²is“used“to“read“the“next“menš¸ãu“ le?‘R®Alternativ˜ely“if“y˜ou“try“to“useŽ¡�’J7 Ï\read–UU²to“read“the“next“menš¸ãu“ le,“ho˜w“do“y˜ou“deal“with“catco�Gde“c˜hanges?ŽŽŽŽŽŒ‹ <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²15ŽŽ ‚��� þ }ü����‘ÕºâŸ÷[‰ffRóŸ -€�„ -€ff�Ÿýwz���‘³3Ï\lettermenu{MN}ŽŽŽŽ‘R&9„ -€ffŽžff‰ffRóŽŽŽŽ¤BÅ�‘Õºâ²This–UUis“an“abbreviation“forŽ¡�‘ÚúÞÏ\menuMN–?ü\readChar{Q}\reply“\optionexec\replyŽ¡�‘Õºâ²It–"Acalls“the“menš¸ãu“function“asso�Gciated“with“the“men˜u“name“ÏMN²,“reads“a“single“upp�Ger-ޤ �‘Õºâcase–nFletter“inš¸ãto“Ï\reply²,‘tƒand“then“calls“Ï\optionexec“²to“branc˜h“to“the“case“selectedŽ¡�‘Õºâb�¸ãy–UUthe“reply‘ÿ*ª.ޤBÅ����‘ÕºâŸ÷[‰ffÖ2¶Ÿ ‘�„ ‘ff�Ÿüé���‘³3Ï\if\xoptiontest\answer–?ü...“\else“...“\fiŽŽŽŽ’Õeê„ ‘ffŽžff‰ffÖ2¶ŽŽŽŽ¡�‘Õºâ²The–z2function“Ï\xoptiontest“²is“for“use“with“Ï\readline“²or“Ï\xreadline²,‘ƒito“trap“theޤ �‘Õºâsp•Gecial›Ù(resp“onses˜Ï?–?ýQ“q“X“x˜²b•Gefore˜executing˜some˜conditional˜co“de.‘ýAIt˜returns˜aŽ¡�‘Õºâ`true'–¶þv‘ÿqÇalue“suitable“for“Ï\if“²testing,‘Ö©if“and“only“if“the“replacemen�¸ãt“text“of“Ï\answer“²isŽ¡�‘Õºâa–L€single“cš¸ãharacter“matc˜hing“one“of“those“listed.‘nÕThis“is“used“when“y˜ou“are“prompt-Ž¡�‘Õºâing–c×for“a“respšGonse“that“can“b˜e“an“arbitrary“string“of“cš¸ãharacters,‘”$but“y˜ou“w˜an˜t“to“allo˜wŽ¡�‘Õºâthe–5user“still“to“get“help“or“quit“with“the“same“one-c�¸ãharacter“resp�Gonses“that“are“rec-Ž¡�‘Õºâognized–UUin“other“situations.ŽŸÀK��‘Õºâà2.2Ž‘ôzâImplemen� tationŽŸç�‘Õºâ²Standard–UUpacš¸ãk‘ÿqÇage“iden˜ti cation:Ž© ¡c�‘ÕºâÅ%<*2e>ޤ �‘Õºâ\NeedsT–ÿ:«eXF“ormat{LaT“eX2e}Ž¡�‘Õºâ\Pro•¾9videsP“ac“k‘ÿ|rage{men“us}[1994/11/08‘Tv0.9x]ŽŸ¡c�‘Õºâ²Load–UUthe“dialog“pac�¸ãk‘ÿqÇage“if“necessary‘ÿ*ª.ަ�‘ÕºâÅ\RequireP•¾9ac“k‘ÿ|rage{dialog}Ž¡�‘Õºâ%ŽŸ¡c�‘äºâ²This–-î le“requires“Ïgrabhedr.sty“²and“Ïdialog.sty².‘û’If“Ïgrabhedr.sty“²is“not“al-ޤ �‘Õºâready–¾îloaded,›ÙTload“it“no�¸ãw“and“call“Ï\fileversiondate²,˜since“it's“to�Go“late“to“applyŽ¡�‘ÕºâÏ\inputfwh–UU²to“Ìthis‘'v² le.‘qÇSee“the“do�Gcumen�¸ãtation“of“Ï\trap.input“²in“Ïgrabhedr.doc².ަ�‘ÕºâÅ%<*209>ޤ �‘Õºâ\csname‘Ttrap.input\endcsnameŽ¡�‘Õºâ\input–Tgrabhedr.st�¾9y“\relaxŽ¡�‘Õºâ\ lev•¾9ersiondate{men“us.st“y}{0.9x}{1994/11/08}ŽŸBÅ�‘Õºâ\inputfwh{dialog.st�¾9y}Ž¡�‘Õºâ%ŽŸÀK��‘Õºâà2.3Ž‘ôzâDe nitionsŽŸç�‘Õºâ²W‘ÿ*ªe–û%start“bš¸ãy“using“the“Ï\localcatcodes“²function“from“Ïgrabhedr.sty“²to“sa˜v˜e“cur-ޤ �‘Õºâren�¸ãt–ȧcatcošGdes“and“set“new“catco˜des“for“certain“signi canš¸ãt“c˜haracters,‘å{as“explainedŽ¡�‘Õºâat–UUmore“length“in“Ïdialog.doc².ŽŽ� þ }ü�’J7 Å\lo•AÇcalcatco“des{\@{11}%ŽŸ �’Pa´\~{13}\"{12}\#{6}\^{7}\`{12}\${3}\:{12}}ŽŸL÷�’J7 Ï\menuprefix–i²is“a“string“added“at“the“b�Geginning“of“eacš¸ãh“men˜u“to“prett˜y“it“up“a“lit-ޤ �’J7 tle–év(or“uglify“it“a“little,‘ÿ dep�Gending“on“y�¸ãour“taste).‘MÒThe“length“of“the“default“string“isŽ¡�’J7 70–}Õcš¸ãharacters,‘‡õnot“coun˜ting“the“t˜w˜o“newline“c˜haracters.‘ëGBy“using“Ï\storexmesj“²w˜eŽ¡�’J7 get–וem�¸ãbšGedded“newlines“corresp˜onding“to“the“ones“seen“here.‘GÝ[That“is,‘ð¼except“for“theŽ¡�’J7 extra–³¡line“break“(where“the“newline“cš¸ãharacter“is“commen˜ted“out),‘Ë4needed“to“mak˜eŽ¡�’J7 this–UU t“in“the“curren�¸ãt“column“width.]ŽŸë–�’OwÏ\storexmesj\menuprefix{Ž¡�’Ow===================================%Ž¡�’Ow===================================Ž¡�’Ow}ŽŸÂÂ�’J7 ²The–UUdefault“v‘ÿqÇalue“for“Ï\menusuffix“²is“the“same“as“for“Ï\menuprefix².Ž©%�’J7 Å\let\men•¾9usux=\men“upre xŽŸ×,�’J7 ²The–à–default“for“Ï\inmenuA“²and“Ï\inmenuB“²is“a“single“newline,‘fwhic�¸ãh“will“pro�Gduce“aŽ¡�’J7 blank–ËÐline“on“screen“bšGecause“they“will“o˜ccur“after“an“Ï\endmenuline²,‘çQwhic�¸ãh“also“con-Ž¡�’J7 tains–UUa“newline.ަ�’J7 Å\storemesj\inmen�¾9uA{ޤ �’J7 }Ž¡�’J7 \storemesj\inmen�¾9uB{Ž¡�’J7 }ޤ×,�’J7 ²The–yÇdefault“v‘ÿqÇalue“for“Ï\menuline“²is“t•¸ãw“o–yÇspaces.‘(˜This“means“that“eac�¸ãh“line“in“the“mid-ŽŸ �’J7 dle–UUsection“of“a“menš¸ãu“de ned“b˜y“Ï\fmenu“²or“Ï\fxmenu“²will“b�Ge“inden˜ted“t˜w˜o“spaces.ަ�’J7 Å\storemesj\men�¾9uline{‘*¨}Ž¡�’J7 ²By–default,‘òno“spaces“are“added“at“the“bšGeginning“of“a“line“in“the“top“or“b˜ottom“sec-ŽŸ �’J7 tion–UUof“a“men�¸ãu:ަ�’J7 Å\def\men�¾9utopline{}ŽŸ �’J7 \def\men�¾9ub�AÇotline{}Ž¡�’J7 Ï\endmenuline–UU²is“just“a“newline.ަ�’J7 Å\storemesj\endmen�¾9uline{ŽŸ �’J7 }%Ž¡�’J7 ²This–tde nition“of“Ï\menunumber“²adds“square“brac•¸ãk“ets–tand“a“follo�¸ãwing“space“aroundŽŸ �’J7 eacš¸ãh–UUitem“n˜um˜b�Ger.ަ�’J7 Å\def\men•¾9un“um“b�AÇer#1{[#1]‘T}ŽŽŽŽŽŒ‹&F <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²16ŽŽ ‚��� þ }ü�‘ÕºâThis–ê[de nition“of“Ï\menuprompt“²is“suitable“for“the“purp�Goses“of“Ïlistout.tex“²but“willޤ �‘Õºâprobably–UUneed“to“b�Ge“no-op'd“or“c�¸ãhanged“for“other“applications.Ž©±ª�‘ÕºâÅ\def\men•¾9uprompt{\promptmesj{Y‘ÿ:«our›Tc“hoice?˜}}ŽŸC�����¡ŽŽŽŽ‘Õºâ²Eacš¸ãh–UUof“the“three“pieces“of“a“men˜u“gets“its“o˜wn“tok˜en“register.ަ�‘ÕºâÅ\newtoks\men�¾9u rstpartޤ �‘Õºâ\newtoks\men•¾9uc“hoicesŽ¡�‘Õºâ\newtoks\men�¾9ulastpartŽ©C�‘Õºâ²The–lë`argumenš¸ãts'“of“Ï\fmenu“²are“Ï#1“²men˜u“name,‘rÑÏ#2“²optional“argumen˜t“sp�Geci ers,‘rÑÏ#3ޤ �‘Õºâ²preliminary–étext,‘LNÏ#4“²list“of“menš¸ãu“c˜hoices,‘LNÏ#5“²follo˜wing“text.‘„But“at“ rst“w˜e“readŽ¡�‘Õºâonly–‚the“ rst“t•¸ãw“o–‚b�Gecause“wš¸ãe“w˜an˜t“to“c˜hange“some“catcošGdes“b˜efore“reading“the“oth-Ž¡�‘Õºâers.‘qÇThe–UUauxiliary“function“Ï\fxmenub“²is“shared“with“Ï\fxmenu².ŽŸ PÂ�‘äºâBecause–½µof“the“catco�Gde“cš¸ãhanges“done“b˜y“Ï\mesjsetup²,–×Ínewlines,“spaces,“or‘½µp�Ger-Ž¡�‘Õºâcenš¸ãt–*fsigns“b�Get˜w˜een“the“three“ nal“argumen˜ts“will“not“b�Ge“ignored.‘ðûT‘ÿ*ªo“get“aroundŽ¡�‘Õºâthis,›'ðw�¸ãe––use“the“p�Geculiar“Ï#{“²feature“of“T�‘þU>Ÿ'EŽ‘ãxX,˜in“inš¸ãtermediate“scratc˜h“functions“calledŽ¡�‘ÕºâÏ\@tempa²,‘óØto–Ô%read“and“discard“anš¸ãything“that“ma˜y“ošGccur“b˜et•¸ãw“een–Ô%one“closing“braceŽ¡�‘Õºâand–[´the“next“op�Gening“brace.‘„äT‘ÿ*ªokš¸ãen“register“assignmen˜ts“are“used“to“read“the“argu-Ž¡�‘Õºâmen�¸ãts‘UUprop�Ger.ŽŸl�‘ÕºâÅ\def\fmen�¾9u#1#2#{\mesjsetupޤ �‘ÛåŠ\catco�AÇde`\#=6–T%“for“parametersŽ¡�‘ÛåŠ\toks@{\fxmen�¾9ub{\gdef}{\b�AÇegingroup}{}#1{#2}}%Ž¡�‘ÛåŠ\def\@tempa##1##{%Ž¡�‘â2\def\@tempa####1####{%Ž¡�‘è:Ú\def\@tempa{\the\toks@}%Ž¡�‘è:Ú\afterassignmen•¾9t\@tempa‘T\men“ulastpart}%Ž¡�‘â2\afterassignmen•¾9t\@tempa‘T\men“uc“hoices}%Ž¡�‘ÛåŠ\afterassignmen•¾9t\@tempa‘T\men“u rstpartŽ¡�‘Õºâ}ަ�‘äºâ²Before–9dpro�Gceeding“to“de ne“Ï\fxmenub²,‘r.wš¸ãe“m˜ust“deal“with“a“subproblem.‘"What“w˜eޤ �‘Õºâwill›ÇÛha•¸ãv“e˜to˜w“ork˜with˜is˜three˜pieces˜of˜text˜in˜the˜tok“en˜registers˜Ï\menufirstpart²,Ž¡�‘ÕºâÏ\menuchoices²,–�Îand›„Ï\menulastpart²,“con•¸ãtaining˜activ“e˜Ï^^M˜²c“haracters˜to˜mark˜lineŽ¡�‘Õºâbreaks,‘}áincluding–uÅpšGossibly“but“not“necessarily“Ï^^M“²at“the“b˜eginning“and“at“the“endŽ¡�‘Õºâof–é(eacš¸ãh“piece.‘M¸What“w˜e“w˜ould“lik˜e“to“do,‘þËfor“eac˜h“piece,‘þËis“to“remo˜v˜e“the“ rst“Ï^^M²,‘þËifŽ¡�‘Õºâthere–d0is“one,›gçand“the“last“one,˜if“there“is“one.‘žXThe“function“Ï\stripcontrolMs“²do�GesŽ¡�‘Õºâthis.ŽŸ PÂ�‘äºâIf–líyš¸ãou“are“one“of“those“rare“T�‘þU>Ÿ'EŽ‘ãxX“hac˜k˜ers“who“migh˜t“actually“w˜an˜t“to“under-Ž¡�‘Õºâstand–4the“wš¸ãorkings“of“Ï\stripcontrolMs²,‘Ÿ'EŽ‘ãxX“memory“limits“b˜y“storing“indi-ޤ �’J7 vidual–ïmenš¸ãus“or“groups“of“men˜us“in“separate“ les“and“using“Ï\optionfileexec“²inŽ¡�’J7 place–Çèof“Ï\optionexec“²to“retrievš¸ãe“the“men˜u“text“from“disk“storage“instead“of“fromŽ¡�’J7 main›ƒÈmemory‘ÿ*ª.‘ýHo•¸ãw“ev“er˜there˜are˜a˜n“um“b�Ger˜of˜tec“hnical˜complications˜and˜I‘ƒ¼prob-Ž¡�’J7 ably–UUwš¸ãon't“get“around“to“w˜orking“on“them“in“the“near“future.ŽŸ=ܦ�’J7 Å\def\option leexec#1{\not•¾9y“et\option leexec}ŽŸ1}�’J7 ²The–Šçfunction“Ï\xoptiontest“²m�¸ãust“return“true“if“and“only“if“the“macro“Ï#1“²consists“en-Ž¡�’J7 tirely–Eof“one“of“the“one-letter“respšGonses“Ï?–?ýQ“q“X“x–E²that“corresp˜ond“to“sp˜ecial“men�¸ãuŽ¡�’J7 actions.‘EôThe–œrather“cautious“implemenš¸ãtation“with“Ï\aftergroup“²a˜v˜oids“rescanningŽ¡�’J7 the›UUcon•¸ãten“ts˜of˜Ï#1²,˜just˜in˜case˜it˜con“tains˜an“ything˜that's˜Ï\outer².ަ�’J7 Å\def\xoption�¾9test#1{TT\ ޤ �’Pa´\b�AÇegingroup‘T\def\0{?}\def\1{Q}%Ž¡�’Pa´\def\2{q}\def\3{x}\def\4{X}%Ž¡�’VŒ\\aftergroup\if\aftergroup‘TT%Ž¡�’VŒ\\ifx\0#1\aftergroup‘TT%Ž¡�’VŒ\\else\ifx\1#1\aftergroup‘TT%Ž¡�’VŒ\\else\ifx\2#1\aftergroup‘TT%Ž¡�’VŒ\\else\ifx\3#1\aftergroup‘TT%Ž¡�’VŒ\\else\ifx\4#1\aftergroup‘TT%Ž¡�’VŒ\\else–T\aftergroup“F%Ž¡�’VŒ\\ \ \ \ \ Ž¡�’Pa´\endgroupŽ¡�’J7 }ŽŸ1}�’J7 ²Default–ûhelp“message,‘ (can“b�Ge“rede ned“if“necessary‘ÿ*ª.‘SµThe“extra“newlines“commen�¸ãtedŽŸ �’J7 out–UUwith“Ï%“²are“here“only“for“con•¸ãv“enien“t›UUprin“ting˜within˜a˜narro“w˜column˜width.ŽŸ'—�’J7 Å\fxmesj\men•¾9uhelpmesj{&\men“upre x%ŽŽŽŽŽŒ‹hT <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²20ŽŽ ‚��� þ }ü�‘ÕºâÅA–Tresp�AÇonse“of“Q“will“usually“send“yš¾9ou“bac˜k“to“%ޤ �‘Õºâthe–Tprevious“men�¾9u.Ž¡�‘ÕºâA–Tresp�AÇonse“of“X“will“get“yš¾9ou“en˜tirely“out“of“%Ž¡�‘Õºâthe–Tmen�¾9u“system.Ž¡�‘Õºâ&\men�¾9usux%Ž¡�‘ÕºâPress–Tthe““kš¾9ey“(“En˜ter“)“to“con˜tin˜ue:Ž¡�‘Õºâ}Ž©àUŸ{b�‘Õºâ\def\moptionhelp{%Ž¡�‘ÛåŠ\men�¾9uhelpmesj–T\readline{}\reply“\rep�AÇeatoption}ަ�‘ÕºâÏ\moptionhelp–|²is“the“brancš¸ãh“that“will“b�Ge“tak˜en“if“the“user“en˜ters“a“question“mark“inŽŸ �‘Õºâresp�Gonse–UUto“a“men�¸ãu.ŽŸ{b�‘ÕºâÅ\def\moptionhelp{%Ž¡�‘ÛåŠ\men�¾9uhelpmesj–T\readline{}\reply“\rep�AÇeatoption}ަŸ{b�‘Õºâ\xp@\def\csname‘Tmoption?\endcsname{%Ž¡�‘ÛåŠ\moptionhelp}ަ�‘Õºâ²The–^function“Ï\specialhelp“²can“b�Ge“used“to“pro�¸ãvide“a“one-time“alternate“help“mes-ޤ �‘Õºâsage–®ktailored“to“a“spšGecifc“resp˜onse“givš¸ãen“b˜y“the“user.‘}It“de nes“the“ rst“argumen˜tŽ¡�‘Õºâ(the–#™macro“conš¸ãtaining“the“resp�Gonse)“to“con˜tain“Ï?²,‘-‹then“rede nes“Ï\menuhelpmesj“²toŽ¡�‘Õºâuse–UUthe“message“text“giv�¸ãen“in“arg“Ï#2².ŽŸ{b�‘ÕºâÅ\def\sp�AÇecialhelp#1#2{%ޤ �‘ÛåŠ\let\sp•AÇecialhelpreply=#1\def#1{?}\b“egingroupŽ¡�‘ÛåŠ\def\men�¾9uhelpmesj{\let#1\sp�AÇecialhelpreplyŽ¡�‘â2\promptxmesj{#2\Ž¡�‘ÕºâPress–T“to“con•¾9tin“ue:}\endgroup}%Ž¡�‘Õºâ}ަ�‘Õºâ²Init.ޤ{b�‘ÕºâÅ\def\sp�AÇecialhelpreply{}ަ�‘Õºâ²This–UUis“a“con•¸ãv“enien“t–UUabbreviation“for“an“often-used“com�¸ãbination.Ž¡�‘ÕºâÅ\def\lettermen�¾9u#1{%ޤ �‘ÛåŠ\csname‘Tmen�¾9u#1\endcsnameŽ¡�‘ÛåŠ\readChar{Q}\reply‘T\optionexec\replyŽ¡�‘Õºâ}ަ�‘äºâ²Restore–UUanš¸ãy“catco�Gdes“c˜hanged“lo�Gcally‘ÿ*ª,“and“depart.ŽŸ{b�‘ÕºâÅ\restorecatco�AÇdesŽ¡�‘Õºâ\endinputŽŽ� þ }ü�’J7 àApp�`endixŽŸ�’J7 Miscellaneous–€supp�`ort“functions:‘ágrabhedr.styŽŸfÕ��’J7 àA.1Ž’lhÓIn� tro�`ductionŽ©‡�’J7 ²This–™q le“de nes“a“function“Ï\inputfwh“²to“b�Ge“used“instead“of“Ï\input²,‘ªwto“allo�¸ãw“T�‘þU>Ÿ'EŽ‘ãxXޤ �’J7 to–F/grab“information“from“standardized“ le“headers“in“the“form“prop�Gosed“b�¸ãy“Nel-Ž¡�’J7 son–UUBeeb�Ge“during“his“term“as“presiden�¸ãt“of“the“T�‘þU>Ÿ'EŽ‘ãxX“Users“Group.‘qÇUsage:ޤt‡����’J7 Ÿ÷[‰ffgòùŸ ‘�„ ‘ff�Ÿüé���‘³3Ï\inputfwh{file.nam}ŽŽŽŽ‘g&-„ ‘ffŽžff‰ffgòùŽŽŽŽ¡�’J7 ²F‘ÿ*ªunctions–¦Ï\localcatcodes“²and“Ï\restorecatcodes“²for“managing“catco�Gde“c�¸ãhangesޤ �’J7 are–Äßalso“de ned“herein,‘ Áas“wš¸ãell“as“a“handful“of“utilit˜y“functions,‘ Áman˜y“of“themŽ¡�’J7 b�Gorro•¸ãw“ed–MÚfrom“Ïlatex.tex²:‘bÑÏ\@empty²,–‹ûÏ\@gobble²,“Ï\@gobbletwo²,“Ï\@car²,“Ï\@@input²,Ž¡�’J7 Ï\toks@²,–UUÏ\afterfi²,“Ï\fileversiondate²,“Ï\trap.input².ŽŸ|-�’Y7 The–ñiuse“of“Ï\inputfwh²,–nÏ\fileversiondate²,“and–ñiÏ\trap.input“²as“illustrated“inŽ¡�’J7 Ïdialog.sty–,¶²is“cumš¸ãb�Gersome“klugery“that“in“fact“w˜ould“bšGetter“b˜e“handled“b�¸ãy“appro-Ž¡�’J7 priate–�zfunctionalitš¸ãy“built“in˜to“the“format“ le.‘7But“none“of“the“ma‘Ž8jor“formats“ha˜v˜eŽ¡�’J7 anš¸ãything–vÞalong“these“lines“y˜et.‘Öa(It“w˜ould“also“help“if“T�‘þU>Ÿ'EŽ‘ãxX“made“the“curren˜t“in-Ž¡�’J7 put–UU le“name“accessible,“lik�¸ãe“Ï\inputlineno².)ŽŸ*A��’J7 àA.2Ž’lhÓImplemen� tationަ�’J7 ²Standard–UUpacš¸ãk‘ÿqÇage“iden˜ti cation:Ž©w–�’J7 Å%<*2e>ޤ �’J7 \NeedsT–ÿ:«eXF“ormat{LaT“eX2e}Ž¡�’J7 \Pro•¾9videsP“ac“k‘ÿ|rage{grabhedr}[1994/11/08‘Tv0.9j]Ž¡�’J7 %ŽŸw–�’Y7 ²By–e«enclosing“this“enš¸ãtire“ le“in“a“group,‘iÀsa˜ving“and“restoring“catco�Gdes“`b˜y“hand'ޤ �’J7 is–Îôrendered“unnecessary‘ÿ*ª.‘Þ¤This“is“pšGerhaps“the“b˜est“w•¸ãa“y–Îôto“lo˜cally“c�¸ãhange“catco˜des,Ž¡�’J7 bšGetter–]0than“the“Ï\localcatcodes“²function“de ned“b˜elo�¸ãw.‘‰WBut“it“tends“to“b˜e“incon-Ž¡�’J7 v•¸ãenien“t–&Sfor“the“T�‘þU>Ÿ'EŽ‘ãxX“programmer:‘Âevš¸ãery“time“y˜ou“add“something“y˜ou“ha˜v˜e“to“re-Ž¡�’J7 memš¸ãb�Ger–ûto“mak˜e“it“global;‘.if“y˜ou're“lik˜e“me,‘ &y˜ou“end“up“making“ev˜ery“c˜hange“t˜wice,Ž¡�’J7 with–“an“abšGortiv�¸ãe“test“run“of“T�‘þU>Ÿ'EŽ‘ãxX“in“b˜et•¸ãw“een,‘â‰in›“whic“h˜y“ou˜disco“v“er˜that˜a˜cer-Ž¡�’J7 tain–¦‡conš¸ãtrol“sequence“is“unde ned“b�Gecause“y˜ou“didn't“assign“it“globally‘ÿ*ª.‘e^(UsingŽ¡�’J7 Ï\globaldefs–+`²=“1“is“dangerous“in“mš¸ãy“exp�Gerience;‘9\y˜ou“ha˜v˜e“to“tak˜e“care“not“to“acci-Ž¡�’J7 den•¸ãtally›UUc“hange˜an“y˜v‘ÿqÇariables˜that˜y“ou˜don't˜w“an“t˜to˜b�Ge˜c“hanged˜globally‘ÿ*ª.)ަ�’J7 Å\b�AÇegingroupŽŽŽŽŽŒ‹xÕ <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²21ŽŽ ‚��� þ }ü�‘ÕºâInside–L‘this“group,‘Š`enforce“normal“catcošGdes.‘W|All“de nitions“m�¸ãust“b˜e“global“in“or-ŽŸ �‘Õºâder–UUto“pšGersist“b˜ey�¸ãond“the“Ï\endgroup².Ž© ã$�‘ÕºâÅ\catco�AÇde96–T12“%“left“quoteޤ �‘Õºâ\catco�AÇde`\=‘T12Ž¡�‘Õºâ\catco•AÇde`\{=1›T\catco“de`\}=2˜\catco“de`\#=6Ž¡�‘Õºâ\catco•AÇde`\$=3›T\catco“de`\~=13˜\catco“de`\^=7Ž¡�‘Õºâ\catco•AÇde`\_=8›T\catco“de`\^^M=5˜\catco“de`\"=12ŽŸã$�‘Õºâ²Makš¸ãe–UUÏ@“²a“letter“for“use“in“`priv‘ÿqÇate'“con˜trol“sequences.ަ�‘ÕºâÅ\catco�AÇde`\@=11ŽŸøë��‘ÕºâàA.3Ž‘÷ì©PreliminariesŽŸç�‘Õºâ²F‘ÿ*ªor›žÏ\@empty²,–40Ï\@gobble²,“.–ªª.“.‘3Lw�¸ãe˜use˜the˜L�Ÿýó5�‘üff±AŽŽ‘͉²T�‘þU>Ÿ'EŽ‘ãxX˜names˜so˜that˜if˜Ïgrabhedr.sty˜²isŽŸ �‘Õºâused–UUwith“L�Ÿýó5�‘üff±AŽŽ‘͉²T�‘þU>Ÿ'EŽ‘ãxX“wš¸ãe“w˜on't“w˜aste“hash“table“and“string“p•Go“ol‘UUspace.ޤ©m�‘ÕºâEmpt�¸ãy–UUmacro,“for“Ï\ifx“²tests“or“initialization“of“v‘ÿqÇariables.ަ�‘ÕºâÅ\gdef\@empt�¾9y{}Ž¡�����Ÿ ŽŽŽŽ‘Õºâ²F‘ÿ*ªunctions–UUfor“gobbling“un•¸ãw“an“ted‘UUtok“ens.ަ�‘ÕºâÅ\long\gdef\@gobble#1{}ޤ �‘Õºâ\long\gdef\@gobblet•¾9w“o#1#2{}Ž¡�‘Õºâ\long\gdef\@gobblethree#1#2#3{}ޤ©m�‘Õºâ²The–¡Cfunction“Ï\@car²,›´?though“not“really“needed“b�¸ãy“Ïgrabhedr.sty²,˜is“needed“b�¸ãy“theŽŸ �‘Õºâprincipal–UUcustomers“of“Ïgrabhedr.sty“²(e.g.,“Ïdialog.sty²).ަ�‘ÕºâÅ\long\gdef\@car#1#2\@nil{#1}Ž¡�‘Õºâ²T‘ÿ*ªo–�de ne“Ï\@@input“²as“in“L�Ÿýó5�‘üff±AŽŽ‘͉²T�‘þU>Ÿ'EŽ‘ãxX“wš¸ãe“w˜an˜t“to“let“it“equal“to“the“primitiv˜e“Ï\input².ޤ �‘ÕºâBut–“²if“a“L�Ÿýó5�‘üff±AŽŽ‘͉²T�‘þU>Ÿ'EŽ‘ãxX“format“is“b�Geing“used“wš¸ãe“don't“w˜an˜t“to“execute“that“assignmen˜t“b�Ge-Ž¡�‘Õºâcause–Œ3bš¸ãy“no˜w“Ï\input“²has“c˜hanged“its“meaning.‘`And“if“some“other“format“is“b�GeingŽ¡�‘Õºâused–æit“b•Geho“o•¸ãv“es–æus“to“c•¸ãhec“k,›A b�Gefore–æde ning“Ï\@@input²,˜whether“Ï\input“²still“hasŽ¡�‘Õºâits–žprimitivš¸ãe“meaning.‘\ŠOtherwise“there's“a“go•Go“d–žc˜hance“Ï\inputfwh“²will“fail“to“w˜orkŽ¡�‘Õºâprop�Gerly‘ÿ*ª.ަ�‘ÕºâÅ\ifx\UndEFiNed\@@input–T%“LaT‘ÿ:«eX“not“loaded.ŽŸã$�‘Õºâ²This–½co�Gde“shoš¸ãws“a“fairly“easy“w˜a˜y“to“c˜hec˜k“whether“the“meaning“of“a“primitiv˜e“con-Ž¡�‘Õºâtrol–UUsequence“is“still“the“original“meaning.ަ�‘ÛåŠÅ\edef\0{\meaning\input}\edef\1{\string\input}%ޤ �‘ÛåŠ\ifx\0\1%Ž¡�‘â2\global\let\@@input\inputŽ¡�‘ÛåŠ\elseŽ¡�‘â2\errhelp{%Ž¡�‘ÕºâGrabhedr.stš¾9y–Tneeds“to“kno˜w“the“name“of“theŽ¡�‘Õºâ\input–Tprimitiv�¾9e“in“order“to“de ne“\inputfwhŽŽ� þ }ü�’J7 prop�AÇerly›ÿ:«.–TConsult“a“T˜eXnician“for“help.}ޤ �’VŒ\\errmessage{%Ž¡�’\·Non-primitiv�¾9e–T\no�AÇexpand\input“detected}%Ž¡�’Pa´\ Ž¡�’J7 \ ޤ`�’J7 ²Scratc•¸ãh›UUtok“en˜register.Ž©4Ñ�’J7 Å\global\toksdef\toks@=0Ž¡�’J7 ²Sonja–uñMaus's“function“for“throš¸ãwing“co�Gde“o˜v˜er“the“Ï\fi“²(\An“Expansion“P˜o˜w˜erޤ �’J7 Lemma",‘ùó"p®0J cmsl10ÍTUGb�Goat‘ÜÓ²v�¸ãol–¥12“no“2“June“1991).‘a"(Except“that“she“called“this“func-Ž¡�’J7 tion‘UUÏ\beforefi².)ŽŸLÓ�’J7 Å\long\gdef\after #1\ {\ #1}ŽŸ`�’J7 ²W‘ÿ*ªe–(will“b�Ge“using“Ï\noexpand“²a“lot;‘70this“abbreviation“impro•¸ãv“es–(the“readabilit�¸ãy“of“theŽ¡�’J7 co�Gde.ަ�’J7 Å\global\let\nx@\no�AÇexpandŽŸ`�’J7 ²Another›UUcon•¸ãv“enien“t˜abbreviation.ަ�’J7 Å\global\let\xp@\expandafterŽŸ‘#��’J7 àA.4Ž’lhÓReading–€standard“ le“headersŽŸÉ�’J7 ²The–UŸfunction“Ï\inputfwh“²(`input“ le“with“header')“inputs“the“givš¸ãen“ le,‘•±c˜hec˜kingŽ¡�’J7 rst–Üto“see“if“it“starts“with“a“standardized“ le“header;‘Y if“so,›.>the“ lename,˜v�¸ãersionŽ¡�’J7 and–UUdate“are“scanned“for“and“stored“in“a“con�¸ãtrol“sequence.Ž© �’Y7 F‘ÿ*ªor–Ámaximš¸ãum“robustness,‘Üw˜e“striv˜e“to“rely“on“the“few˜est“p�Gossible“assumptionsŽ¡�’J7 abšGout–UUwhat“the“ le“that“is“ab˜out“to“b˜e“input“mighš¸ãt“con˜tain.ަ�’Y7 Assumption› ‹1:‘2P•¸ãercen“t˜c“haracter˜Ï%˜²has˜category˜14.‘ShI.e.,‘³Xif˜the˜ rst˜line˜of˜theŽ¡�’J7 le–UUto“b�Ge“input“starts“with“Ï%²,“it“is“OK“to“throš¸ãw“a˜w˜a˜y“that“line.ŽŸx ©4Ñ�’J7 Å\b•AÇegingroup‘T\lcco“de`\.=`\%%ޤ �’J7 \lo•¾9w“ercase{\gdef\@p�AÇercen“tc“har{.}}%Ž¡�’J7 \endgroupŽŸ`�’J7 ²The–aÁfunction“Ï\fileversiondate“²is“not“only“a“useful“supp�Gort“function“forޤ �’J7 Ï\inputfwh²,‘²Rit–Ÿ¹can“also“bšGe“used“b�¸ãy“itself“at“the“b˜eginning“of“a“ le“to“set“ le“name,Ž¡�’J7 vš¸ãersion,‘…#and–-date“correctly“ev˜en“if“the“ le“is“input“b˜y“some“means“other“thanŽ¡�’J7 Ï\inputfwh²|assuming–@nthat“the“argumen�¸ãts“of“the“Ï\fileversiondate“²command“areŽ¡�’J7 k�¸ãept–UUprop�Gerly“up“to“date.ަ�’J7 Å\gdef\ lev�¾9ersiondate#1#2#3{%ŽŸ �’Pa´\xp@\xdef\csname#1\endcsname{#2‘T(#3)}%ŽŽŽŽŽŒ‹ŠB <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²22ŽŽ ‚��� þ }ü�‘ÛåŠÅ\def\ lename{#1}\def\ lev�¾9ersion{#2}%ޤ �‘ÛåŠ\def\ ledate{#3}%Ž¡�‘ÛåŠ\message{#1‘T\csname#1\endcsname}%Ž¡�‘Õºâ}ŽŸî£�‘Õºâ²And–UUno�¸ãw“apply“Ï\fileversiondate“²to“this“ le.Ž© î£�‘ÕºâÅ%<*209>Ž¡�‘Õºâ\ lev•¾9ersiondate{grabhedr.st“y}{0.9j}{1994/11/08}Ž¡�‘Õºâ%ŽŸËé�‘ÕºâÏfilehdr.el–Ýɲbš¸ãy“default“adds“a“string“of“equal“signs“(with“an“initial“commen˜t“pre-ޤ �‘Õºâ x)–†~at“the“vš¸ãery“top“of“a“ le“header.‘CThis“string“m˜ust“b�Ge“scanned“a˜w˜a˜y“ rst“b�GeforeŽ¡�‘Õºâw�¸ãe–UUcan“start“lo�Goking“for“the“real“information“of“the“ le“header.ަ�‘ÕºâÅ\xdef\@ lehdrstart{%ޤ �‘ÛåŠ\@pšAÇercen•¾9tc“har\@p˜ercen“tc“har\@p˜ercen“tc“har\spaceŽ¡�‘ÛåŠ==================================%Ž¡�‘ÛåŠ==================================}ŽŸËé�‘Õºâ²The–‡purpšGose“of“this“function“is“just“to“scan“up“to“the“op˜ening“brace“that“marks“theޤ �‘ÕºâbšGeginning– of“the“ le“header“b˜o˜dy‘ÿ*ª.‘YÕEv�¸ãerything“b˜efore“that“is“ignored,‘Ýnot“needed“forŽ¡�‘Õºâour–UUpresen�¸ãt“purp�Goses.ަ�‘ÕºâÅ\gdef\@scan leheader#1@#2#{\@xscan leheader}ŽŸËé�‘Õºâ²Throš¸ãw–yùin“some“dumm˜y“v‘ÿqÇalues“of“v˜ersion“and“date“at“the“end“so“that“all“w˜e“re-Ž¡�‘Õºâquire–UUfrom“a“ le“header“is“that“the“ lename“ eld“mš¸ãust“b�Ge“presen˜t.ަ�‘ÕºâÅ\long\gdef\@xscan leheader#1{%ޤ �‘ÛåŠ\@yscan leheader#1{}–Tv�¾9ersion“=“"??",Ž¡�‘ÛåŠdate–T=“"??",\@yscan leheader}ŽŸËé�‘Õºâ²This–úófunction“assumes“that“ lename,– v�¸ãersion,“and–úódate“of“a“ le“are“listed“in“that“or-ޤ �‘Õºâder–Ƚ(but“not“necessarily“adjacenš¸ãt).‘ÌIt's“p�Gossible“for“the“v˜ersion“and“date“to“b�GeŽ¡�‘Õºâmissing,›3ˆor–out“of“order,˜but“the“corresp�Gonding“T�‘þU>Ÿ'EŽ‘ãxX“v‘ÿqÇariables“Ï\fileversion“²andŽ¡�‘ÕºâÏ\filedate–xÞ²will“not“get“set“prop�Gerly“unless“the“order“is:‘¸Ø lename,›Á¿[.–ªª.“.“,]˜v�¸ãersion,Ž¡�‘Õºâ[.–ªª.“.“,]‘6/date.‘�kT‘ÿ*ªrying– 6to“handle“di erenš¸ãt“orderings“w˜ould“b�Ge“desirable“but“I‘ ha˜v˜en'tŽ¡�‘Õºâyš¸ãet–>“b�Geen“struc˜k“b˜y“a“suitable“ ash“of“insigh˜t“on“ho˜w“to“do“it“without“grubb˜y‘ÿ*ª,‘C time-Ž¡�‘Õºâconsuming–UUpicš¸ãking“apart“of“the“en˜tire“ le“header.ަ�‘ÕºâÅ\long\gdef\@yscan leheaderޤ �‘ÛåŠ#1–T lename“=“"#2",#3“v�¾9ersion“=“"#4",%Ž¡�‘ÛåŠ#5–Tdate“=“"#6",#7\@yscan leheader{%Ž¡�‘ÛåŠ\endgroupŽ¡�‘ÛåŠ\csname‘T lev�¾9ersiondate\endcsname{#2}{#4}{#6}%Ž¡�‘Õºâ}ŽŸËé�‘Õºâ²This–Õfunction“has“to“lošGok“at“the“ rst“line“of“the“ le“to“see“if“it“has“the“exp˜ected“formŽŸ �‘Õºâfor–UUthe“ rst“line“of“a“ le“header.ŽŽ� þ }ü�’J7 Å\b�AÇegingroupޤ �’J7 \lcco�AÇde`\$=`\^^MŽ¡�’J7 \lo•¾9w“ercase{\gdef\@read rstheaderline#1$}{%Ž¡�’Pa´\toks@{#1}%Ž¡�’Pa´\edef\@tempa{\@p�AÇercen•¾9tc“har\the\toks@}%Ž¡�’Pa´\ifx\@tempa\@ lehdrstartŽ¡�’VŒ\\endgroup‘T\b�AÇegingroupŽ¡�’VŒ\\catco•AÇde`\%=9›T\catco“de`\^^M=5˜\catco“de`\@=11ŽŸ a�’J7 ²Double–ß5quote“and“equals“sign“need“to“b�Ge“category“12“in“order“for“the“parame-ޤ �’J7 ter–Ò'matcš¸ãhing“of“Ï\@xscanfileheader“²to“w˜ork,‘ñ\and“space“needs“its“normal“catco�GdeŽ¡�’J7 of‘UU10.Ž© b�’VŒ\Å\catcošAÇde`\–T=10“\catco˜de`\==12“\catco˜de`\"=12ޤ �’Pa´\xp@\@scan leheaderŽ¡�’Pa´\elseŽ¡�’VŒ\\message{(*–TMissing“ le“header?“*)}%Ž¡�’VŒ\\after \endgroupŽ¡�’Pa´\ }Ž¡�’J7 \endgroupŽŸ»=�’J7 ²An–UUauxiliary“function.ަ�’J7 Å\gdef\@xinputfwh{%Ž¡�’Pa´\ifx\next\@read rstheaderlineŽŸ a�’J7 ²Sanitize–»Qa“few“cš¸ãharacters.‘£»Otherwise“an“unmatc˜hed“brace“or“other“sp�Gecial“c˜harac-ޤ �’J7 ter–‹Àmigh�¸ãt“cause“a“problem“in“the“pro�Gcess“of“reading“the“ rst“line“as“a“macro“argu-Ž¡�’J7 men�¸ãt.ަ�’VŒ\Å\catco•AÇde`\%=12›T\catco“de`\{=12˜\catco“de`\}=12ޤ �’VŒ\\catco•AÇde`\\=12‘T\catco“de`\^^L=12Ž¡�’VŒ\\catco�AÇde`\^=12Ž¡�’J7 %‘ UPUnique–Tterminator“tok�¾9en“for“the“ rst“line.Ž¡�’VŒ\\catco�AÇde`\^^M=3\relaxŽ¡�’Pa´\else‘T\endgroup\ Ž¡�’J7 }ޤ»=�’J7 ²Auxiliary–UUfunction,“carries“out“the“necessary“Ï\futurelet².ަ�’J7 Å\gdef\@inputfwh{\futurelet\next\@xinputfwh}Ž¡�’J7 ²Strategy–pûfor“(almost)“bulletpro�Gof“reading“of“the“ rst“line“of“the“input“ le“is“lik�¸ãeޤ �’J7 this:‘%ãGivš¸ãe–/cthe“p�Gercen˜t“sign“a“spšGecial“catco˜de,‘eæthen“use“Ï\futurelet“²to“freeze“theŽ¡�’J7 catco�Gde–”²of“the“ rst“tokš¸ãen“in“the“input“ le.‘/ÝIf“the“ rst“tok˜en“is“Ìnot‘‡Š²a“p�Gercen˜t“c˜har-Ž¡�’J7 acter,–ÂDthen›¬z ne,“just˜close˜the˜group˜wherein˜the˜p�Gercen•¸ãt˜c“haracter˜had˜its˜sp�GecialŽ¡�’J7 catco•Gde,‘X3and›$mpro“ceed˜with˜normal˜input;‘‹ùthe˜ rst˜tok•¸ãen˜will˜ha“v“e˜its˜prop�Ger˜cat-Ž¡�’J7 co•Gde›H�b“ecause˜w•¸ãe˜did˜not˜c“hange˜an“ything˜except˜the˜p�Gercen“t˜c“haracter.‘m…Otherwise,ŽŽŽŽŽŒ‹œ– <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²23ŽŽ ‚��� þ }ü�‘Õºâwš¸ãe–É~still“pro�Gceed“with“`normal'“input“execution,‘æˆbut“b˜y“making“Ï%“²activ˜e“and“de n-ޤ �‘Õºâing–{it“suitably‘ÿ*ª,‘Äsw�¸ãe“can“carry“out“further“tests“to“see“if“the“ rst“ le“line“has“theŽ¡�‘ÕºâexpšGected–UUform“(three“p˜ercen�¸ãt“signs“plus“lots“of“equal“signs).Ž© Ùý�‘ÕºâÅ\gdef\inputfwh#1{%ޤ �‘ÛåŠ\b•AÇegingroup\catco“de`\%=\activ�¾9eŽ¡�‘ÛåŠ\endlinec�¾9har`\^^M\relaxŽ¡�‘ÛåŠ\lcco�AÇde`\~=`\%\relaxŽ¡�‘ÛåŠ\lo•¾9w“ercase{\let~}\@read rstheaderlineŽ¡�‘ÛåŠ\xp@\@inputfwh\@@input‘T#1\relaxŽ¡�‘Õºâ}ŽŸñ��‘ÕºâàA.5Ž‘÷ì©Managing–€catco�`de“c� hangesŽŸç�‘Õºâ²A‘Énsurvš¸ãey–ÉŒof“other“metho�Gds“for“sa˜ving“and“restoring“catco�Gdes“w˜ould“b�Ge“more“w˜orkޤ �‘Õºâthan›¦ƒI‘¦,ha•¸ãv“e˜time˜for˜at˜the˜momen“t.‘eQThe˜metho�Gd˜giv“en˜here˜is˜the˜b�Gest˜one˜IŽ¡�‘Õºâknoš¸ãw–m(other“metho�Gds“use“up“one“extra“con˜trol“sequence“name“p�Ger“ le,‘rìor“don't“ro-Ž¡�‘Õºâbustly–UUhandle“mš¸ãultiple“lev˜els“of“ le“nesting).ŽŸ�ö�‘ÕºâThe–ÌÛÏ\localcatcodes“²function“cš¸ãhanges“catco�Gdes“according“to“the“c˜haracter/catco�GdeŽ¡�‘Õºâpairs–¢6givš¸ãen“in“its“argumen˜t,‘õnsa˜ving“the“previous“catco�Gde“v‘ÿqÇalues“of“those“c˜harac-Ž¡�‘Õºâters–>Šon“a“stacš¸ãk“so“that“they“can“b�Ge“retriev˜ed“later“with“Ï\restorecatcodes².‘j.Exam-Ž¡�‘Õºâple:ޤ³ù����‘ÕºâŸ÷[‰ff¦òÕŸ -€�„ -€ff�Ÿýwz���‘³3Ï\localcatcodes{\@{11}\"\active}ŽŽŽŽ’¦& „ -€ffŽžff‰ff¦òÕŽŽŽŽ¡�‘Õºâ²to–ÏÁc�¸ãhange“the“catcošGde“of“Ï\@“²to“11“(letter)“and“the“catco˜de“of“Ï"“²to“13“(activ�¸ãe).ޤ �‘ÕºâIn–„|ë[plain‘ª®²T�‘þU>Ÿ'EŽ‘ãxX“y�¸ãou'd“bšGetter“b˜e“careful“to“use“Ï+“²instead“of“Ï\+“²in“the“argumen�¸ãt“ofŽ¡�‘ÕºâÏ\localcatcodes–UU²b�Gecause“of“the“outerness“of“Ï\+².Ž¡�‘äºâThis–b³function“wš¸ãorks“b˜y“using“tok˜en“registers“0“and“4“to“accum˜ulate“catco�Gde“as-Ž¡�‘Õºâsignmen•¸ãt›]æstatemen“ts:‘‚éin˜Ï\toks0˜²w“e˜put˜the˜statemen“ts˜necessary˜to˜restore˜cat-Ž¡�‘Õºâco�Gdes–ö–to“their“previous“v‘ÿqÇalues,‘ ‰while“in“Ï\toks‘?ý4“²wš¸ãe“put“the“statemen˜ts“necessary“toŽ¡�‘Õºâset–UUcatco�Gdes“to“their“new“v‘ÿqÇalues.ަ�‘ÕºâÅ\gdef\lo•AÇcalcatco“des#1{%ޤ �‘ÛåŠ\ifx\@empt•¾9y\@catco�AÇdestac“kŽ¡�‘â2\gdef\@catco�AÇdestac�¾9k{{}}%Ž¡�‘ÛåŠ\ Ž¡�‘ÛåŠ\def\do##1##2{%Ž¡�‘â2\ifn�¾9um##2>\z@Ž¡�‘è:Ú\catcošAÇde\n•¾9um“b˜er`##1‘T\spaceŽ¡�‘è:Ú\n•¾9um“b•AÇer\catco“de`##1\relaxŽ¡�‘â2\expandafter\do\ }%Ž¡�‘ÛåŠ\xdef\@catco�AÇdestac�¾9k{{\do#1\relax\m@ne}%Ž¡�‘â2\@catco�AÇdestac�¾9k}%Ž¡�‘ÛåŠ\def\do##1##2{\catco�AÇde`##1‘T##2\relax\do}%Ž¡�‘ÛåŠ\do#1\‘T{\catco�AÇde32\let\do}%ŽŽ� þ }ü�’J7 }Ž©ïœ�’J7 ²Init–زthe“stacš¸ãk“with“an“empt˜y“elemen˜t;‘`otherwise“p�Gopping“the“next-to-last“elemen˜tޤ �’J7 wš¸ãould–rÒwrongly“remo˜v˜e“braces“from“the“last“elemen˜t.‘&GBut“as“a“matter“of“fact“w˜e“couldŽ¡�’J7 just–ÔCas“wš¸ãell“initialize“Ï\@catcodestack“²to“empt˜y“b�Gecause“Ï\localcatcodes“²is“care-Ž¡�’J7 ful–UUto“add“an“emptš¸ãy“ nal“elemen˜t“if“necessary‘ÿ*ª.ޤ–�’J7 Å\gdef\@catco�AÇdestac�¾9k{{}}ަ�’J7 ²The–°Gfunction“Ï\restorecatcodes“²has“to“pšGop“the“stac�¸ãk“and“execute“the“p˜opp˜ed“co˜de.Ž¡�’J7 Å\gdef\restorecatco�AÇdes{%ޤ �’Pa´\b�AÇegingroupŽ¡�’Pa´\ifx\@empt•¾9y\@catco�AÇdestac“kŽ¡�’VŒ\\errmessage{Can't–TpšAÇop“catco˜des;Ž¡�’\·\nx@\@catco�AÇdestacš¾9k–T=“empt˜y}%Ž¡�’VŒ\\endgroupŽ¡�’Pa´\elseŽ¡�’VŒ\\def\do##1##2\do{%Ž¡�’\·\gdef\@catco�AÇdestac�¾9k{##2}%ŽŸ–�’J7 ²Notice–íthe“placemenš¸ãt“of“Ï#1“²after“the“Ï\endgroup²,‘so“that“the“catco�Gde“assignmen˜tsŽ© �’J7 are–UUlo�Gcal“assignmen�¸ãts.ŽŸ–�’\·Å\endgroup##1}%Ž¡�’VŒ\\xp@\do\@catco�AÇdestac�¾9k\doŽ¡�’Pa´\ Ž¡�’J7 }ŽŸ£#��’J7 àA.6Ž’lhÓT‘þàrapping–€redundanš t“input“statemen˜tsŽŸͳ�’J7 ²The–6Îutilitš¸ãy“Ïlistout.tex“²calls“Ïmenus.sty²,‘<éwhic˜h“calls“Ïdialog.sty²,‘<éand“all“three“ofަ�’J7 these–Ö­ les“start“bš¸ãy“loading“Ïgrabhedr.sty“²in“order“to“tak˜e“adv‘ÿqÇan˜tage“of“its“functionsަ�’J7 Ï\fileversiondate²,–{qÏ\localcatcodes²,“and– lÏ\inputfwh².‘ š But“consequen�¸ãtly‘ÿ*ª,‘{qwhenަ�’J7 Ïlistout.tex–x޲is“used“there“will“b�Ge“t•¸ãw“o›xŽredundan“t˜attempts˜to˜load˜Ïgrabhedr.sty².ަ�’J7 The›â¡straigh•¸ãtforw“ard˜w“a“y˜to˜a“v“oid˜the˜redundan“t˜input˜attempts˜w“ould˜b�Ge˜to˜sur-ަ�’J7 round–UUthem“with“an“Ï\ifx“²test:ޤ÷Î�’OwÏ\ifx\undefined\fileversiondateަ�’Y÷\input–?ügrabhedr.sty“\relaxަ�’Y÷\fileversiondate{foo.bar}{0.9e}{10-Jun-1993}ަ�’Ow\fiŽ¡�’J7 ²This–sômetho�Gd“has“a“few“dra•¸ãwbac“ks,‘{šho“w“ev“er:‘ ¯(1)–sôthe“conditional“remainsަ�’J7 opšGen–¿“throughout“the“pro˜cessing“of“ev�¸ãerything“in“Ïgrabhedr.sty“²and“theަ�’J7 Ï\fileversiondate›�3²statemen•¸ãt,‘¯+whic“h˜mak“es˜an“y˜Ï\else˜²or˜Ï\fi˜²mismatc“h˜problemsަ�’J7 harder–G™to“debug;‘L-(2)“if“Ï\undefined“²b�Gecomes“acciden�¸ãtally“de ned“the“Ï\ifx“²test“willŽŽŽŽŽŒ‹®÷ <æ� ýÊ}ü��’Ï¡CÅINTERA�¾9CTION–TTOOLS:“ÊDIALOG.STY“ÅAND“ÊMENUS.STY’ùæa²24ŽŽ ‚� þÝ}ü�� ÿ.�‘Õºâfail;‘½í(3)–r9cš¸ãho�Gosing“the“righ˜t“con˜trol“sequence“to“test“against“Ï\undefined“²requires“a“lit-ޤ �‘Õºâtle‘UUcare.Ž¡�‘äºâIn–\®a“situation“where“wš¸ãe“kno˜w“that“the“ le“to“b�Ge“input“has“had“Ï\fileversiondateŽ¡�‘Õºâ²applied–‘¢to“it,› µif“it“w�¸ãas“already“input,˜then“wš¸ãe“ha˜v˜e“a“failsafe“con˜trol“sequence“thatŽ¡�‘Õºâw�¸ãe–îªcan“test“to“ nd“out“whether“the“ le“has“already“b�Geen“input|the“name“of“theŽ¡�‘Õºâ le.‘[ýAssuming–÷a“standard“form“for“the“input“statemenš¸ãt“(one“that“will“w˜ork“with“ei-Ž¡�‘Õºâther–uúplain“T�‘þU>Ÿ'EŽ›ãxX“or“L�Ÿýó5�‘üff±AŽŽ‘͉²T�‘þU>Ÿ'EŽ˜X,›~#and“mak�¸ães“as“few“assumptions“as“p�Gossible),˜w�¸ãe“can“writeŽ¡�‘Õºâa–àºfunction“that“will“trap“input“statemenš¸ãts“and“execute“them“only“if“the“giv˜en“ leŽ¡�‘Õºâhas–UUnot“y�¸ãet“b�Geen“loaded:ŽŸª«�‘ÚúÞÏ\csname‘?ütrap.input\endcsnameŽ¡�‘ÚúÞ\input–?ügrabhedr.sty“\relaxŽ¡�‘ÚúÞ\fileversiondate{foo.bar}{1.2}{1993-Jun-07}ŽŸUV�‘Õºâ²The–tkfunction“Ï\trap.input“²scans“for“an“input“statemen�¸ãt“in“canonical“form“and“ex-Ž¡�‘Õºâecutes–îtit“if“and“only“if“the“ le“has“not“y�¸ãet“b�Geen“input“(more“precisely‘ÿ*ª,‘¼if“the“con-Ž¡�‘Õºâtrol–Šssequence“consisting“of“the“ le“name“is“unde ned,‘—ºwhic�¸ãh“means“that“it“has“notŽ¡�‘Õºâhad–:ªÏ\fileversiondate“²applied“to“it).‘!ÇThe“canonical“form“that“I‘:oconsider“to“b�GeŽ¡�‘Õºâthe–wõb�Gest“is“Ï\input�“¸hÌful‘‚ØlŽ�‘á­ leŽ�‘) ¹name‘À[¸iŽ‘EGrÏ \relax².‘Ù¨Ha�¸ãving“the“Ï\relax“²means“that“the“in-ŽŽ� ÿ.�’J7 put–$?statemenš¸ãt“will“not“try“to“expand“b�Gey˜ond“the“end“of“the“line“if“Ï\endlinechar“²isޤ �’J7 catco�Gded–bÎto“9“(ignore),‘“Pas“is“done“rather“frequenš¸ãtly“no˜w“b˜y“progressiv˜e“T�‘þU>Ÿ'EŽ‘ãxX“program-Ž¡�’J7 mers.‘1 The–“Ï\relax“²w�¸ãould“ordinarily“render“the“space“after“the“ le“name“unnecessary‘ÿ*ª,Ž¡�’J7 but–%ÑI‘%Åprefer“leaš¸ãving“the“space“in“to“a˜v˜oid“in˜terfering“with“rede nitions“of“Ï\input“²toŽ¡�’J7 takš¸ãe–a“space-delimited“argumen˜t“that“are“o�Gccasionally“done“to“ac˜hiev˜e“other“sp�Ge-Ž¡�’J7 cial–gRe ects“(see,›–ìfor“example,˜\Organizing“a“large“collection“of“st•¸ãyle les",˜b“y‘gRAngelik‘ÿqÇaŽ¡�’J7 Binding,–˜²ÍCahiers‘i‰GUT‘ÿ*ªenš¸ãb�Gerg²,“n˜um˜‘ûGero‘i‰10{11,“septem˜bre›i‰1991,“p.˜175.)‘#.L�Ÿýó5�‘üff±AŽŽ‘͉²T�‘þU>Ÿ'EŽ‘ãxX's˜argu-Ž¡�’J7 men�¸ãt–)úform“Ï\input{...}“²cannot,–2¦unfortunately‘ÿ*ª,“b�Ge–)úthe“canonical“form“if“ë[plain‘ª®²T�‘þU>Ÿ'EŽ‘ãxXŽ¡�’J7 compatibilit�¸ãy–UUis“required.Ž©‘L�’J7 Å\expandafter\gdef\csname‘Ttrap.input\endcsnameޤ �’Pa´\input#1‘T\relax{%Ž¡�’VŒ\\expandafter\ifx\csname#1\endcsname\relaxŽ¡�’\·\after \inputfwh{#1}\relaxŽ¡�’VŒ\\ }ŽŸÝh�’Y7 ²End–UUthe“group“that“encloses“this“en�¸ãtire“ le,“and“then“call“Ï\endinput².ަ�’J7 Å\endgroupŽ¡�’J7 \endinputŽŽŽŽŽŒøÂƒ’À;è<æ´³3ó`ßê