Debian Codegraph @

texmf-dist/doc/latex/dialogl/diatest.tex

raw
1 % Copyright 1994 Michael John Downes
2 % Copyright 2013 TeX Users Group
3 % This file is part of the dialogl package, released under the LPPL;
4 % see dialogl.ins for details.
5
6 % Test of the `menus' package. You can run this file with (at least)
7 % plain TeX, LaTeX (2e), and old LaTeX (2.09).
8 %
9 % Some chicanery to make this file work in several different contexts.
10 \ifx\undefined\documentclass
11 \def\NeedsTeXFormat#1{}\def\RequirePackage#1{\input #1.sty \relax}
12 \def\ProvidesPackage#1[#2]{}
13 \ifx\undefined\documentstyle
14 \def\startup{\input menus.sty \relax}
15 \else
16 \def\startup{\documentstyle[menus]{article}}
17 \fi
18 \else
19 \def\startup{%
20 \documentclass{article}%
21 \usepackage{menus}%
22 }
23 \fi
24
25 \startup
26
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 \mesj{
29 The following series of tests is designed to cover most of the
30 features that are provided by dialog.sty. If you compare what you
31 see on screen with the contents of the file diatest.tex you will
32 see how they correspond.
33
34 Press the Return or Enter key to continue:}
35 \readline{}\xyz
36
37 \promptmesj{
38
39 Testing \mesj:
40 Press return to continue: }
41 \readline{}\xyz\mesj{}
42 \mesj{Give ~ me %^^L an &|
43 \newif #}
44
45 \promptmesj{
46 Testing \xmesj:
47 Press return to continue: }
48 \readline{}\xyz\mesj{}
49 \xmesj{Do we have \{\}\\ characters?
50 And \iftrue\.true\else\.false\fi.
51 Not to mention ampersand \&, since \string\iftrue.}
52
53 \promptmesj{
54 Testing \xmesj inside of a \def:
55 Press return to continue: }
56 \readline{}\xyz\mesj{}
57 \def\next{\xmesj{Abc space:\ , control-M: \^^M, and percent:\%\
58 and another line break.}}
59 \next
60
61 \promptmesj{
62 Testing \promptmesj:
63 Press return to continue: }
64 \readline{}\xyz\mesj{}
65 \promptmesj{Enter this or that: }
66 \readline{}\xyz
67
68 \promptmesj{
69 Testing \storemesj:
70 Press return to continue: }
71 \readline{}\xyz\mesj{}
72 \storemesj\foo{This is a fine old message, isn't it?:
73 \mesj{Give ~ me %^^L an &|
74 \newif }}
75 \xmesj{\foo}
76
77 \promptmesj{
78 Testing \storexmesj now with an arg:
79 Press return to continue: }
80 \readline{}\xyz\mesj{}
81 \storexmesj\foo#1{This is a fine old message, isn't it?:
82 \\mesj{Give ~ me \%^^L an \&|#1
83 \\newif \#}}
84 \xmesj{\foo{KABLOO}}
85
86 \promptmesj{
87 Testing \fmesj:
88 Press return to continue: }
89 \readline{}\xyz\mesj{}
90 \fmesj\foo{This is a fine old message, isn't it?:
91 \mesj{Give ~ me %^^L an &|
92 \newif}}
93 \foo
94
95 \promptmesj{
96 Testing \fxmesj now with an arg:
97 Press return to continue: }
98 \readline{}\xyz\mesj{}
99 \fxmesj\foo#1{This is a fine old message, isn't it?:
100 \\mesj{Give ~ me \%^^L an \&|#1
101 \\newif \#}}
102 \foo{KABLOO}
103
104 \promptmesj{
105 Would you like to try out \readline? [yes or no]: }
106 \readline{}\answer
107 \xmesj{Well, if I understood you correctly, you answered `\answer'}
108
109 \promptmesj{
110 OK, now try give me an executable answer, such as
111 "\iftrue yes\else no\fi": }
112 \xreadline{}\answer
113 \xmesj{Well, and now if I try to execute that: "\answer"}
114
115 \promptmesj{
116 OK, now let's try \readchar. Give me an arbitrary answer of
117 one or more characters: }
118 \readchar{}\answer
119 \xmesj{Taking the first character from your answer, I get: "\answer"}
120
121 \promptmesj{
122 OK, now let's try \readChar. Give me an arbitrary answer of
123 one or more letters: }
124 \readChar{}\answer
125 \xmesj{Taking the first character from your answer, and
126 uppercasing it, I get: "\answer"}
127
128 \promptmesj{
129 OK, give me a number then, so that I can
130 check it with \checkinteger: }
131 \readline{}\answer
132 \checkinteger\answer\fam
133 \xmesj{\ifnum\fam=-\maxdimen%
134 Gee, I don't think that was\else\.Got\fi%
135 a valid number: "\answer"}
136
137 \def\dimtest#1{\promptxmesj{#1}%
138 \readline{}\answer
139 \ifx\empty\answer
140 \else
141 \checkdimen\answer\vfuzz
142 \ifdim\vfuzz=-\maxdimen%
143 \xmesj{Sorry, that doesn't look like a TeX dimen to me: "\answer"}%
144 \else
145 \xmesj{Looks like a valid TeX dimen: "\answer" = \the\vfuzz}%
146 \fi
147 \expandafter\dimtestb
148 \fi
149 }
150
151 \def\dimtesta{\dimtest{\
152 OK, give me a dimen then, so that I can\
153 check it with \\checkdimen:\
154 }}
155
156 \def\dimtestb{\dimtest{\
157 How about another dimen: }}
158
159 \def\empty{}
160
161 % Iterate once with one prompt, then several times with a shorter
162 % prompt.
163 \dimtesta
164
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166 \csname stop\endcsname
167 \end