| 1 |
% This file is public domain |
| 2 |
|
| 3 |
% This is an interactive script. Run it through \LaTeX |
| 4 |
% and enter appropriate responses. (This won't work with |
| 5 |
% LaTeX2HTML) |
| 6 |
|
| 7 |
\documentclass[a4paper]{article} |
| 8 |
|
| 9 |
\usepackage[utf8]{inputenc} |
| 10 |
\usepackage[T1]{fontenc} |
| 11 |
|
| 12 |
\usepackage{etoolbox} |
| 13 |
|
| 14 |
\usepackage[french,english,spanish,portuges,ngerman,italian]{babel} |
| 15 |
\usepackage{fmtcount} |
| 16 |
|
| 17 |
\newcounter{startval} |
| 18 |
\newcounter{endval} |
| 19 |
\newcounter{stepsize} |
| 20 |
\newcounter{N} |
| 21 |
\newcount\myctr |
| 22 |
\newcount\langid |
| 23 |
|
| 24 |
\newcommand*{\deflangopt}[2][\relax]{% |
| 25 |
\csdef{setlang#2}{\langid=#2#1}% |
| 26 |
} |
| 27 |
\newcommand*{\uselangopt}[1]{\csuse{setlang#1}} |
| 28 |
\deflangopt{1} |
| 29 |
\deflangopt{2} |
| 30 |
\deflangopt{3} |
| 31 |
\deflangopt[\fmtcountsetoptions{french}]{4} |
| 32 |
\deflangopt[\fmtcountsetoptions{french=swiss}]{5} |
| 33 |
\deflangopt[\fmtcountsetoptions{french=belgian}]{6} |
| 34 |
\deflangopt{7} |
| 35 |
\deflangopt{8} |
| 36 |
|
| 37 |
\newcommand*{\defformat}[1]{% |
| 38 |
\csdef{setformat#1}{\numformat=#1\relax}% |
| 39 |
} |
| 40 |
\newcommand*{\useformat}[1]{\csuse{setformat#1}} |
| 41 |
|
| 42 |
\newcommand*{\setformat}{\numformat=1\relax} |
| 43 |
|
| 44 |
\defformat{1} |
| 45 |
\defformat{2} |
| 46 |
\defformat{3} |
| 47 |
\defformat{4} |
| 48 |
\defformat{5} |
| 49 |
\defformat{6} |
| 50 |
|
| 51 |
\newcommand*{\defgender}[2]{% |
| 52 |
\csdef{setgender#1}{\myctr=#2\relax}% |
| 53 |
} |
| 54 |
\newcommand*{\usegender}[1]{\csuse{setgender#1}} |
| 55 |
|
| 56 |
\defgender{}{1} |
| 57 |
\defgender{m}{1} |
| 58 |
\defgender{f}{2} |
| 59 |
\defgender{n}{3} |
| 60 |
|
| 61 |
\begin{document} |
| 62 |
|
| 63 |
\section{Displaying the value of a counter} |
| 64 |
|
| 65 |
\typeout{This is an interactive script, testing the fmtcount package.} |
| 66 |
|
| 67 |
\langid=-1 |
| 68 |
|
| 69 |
\loop |
| 70 |
\typeout{Which language?^^J} |
| 71 |
\typeout{[1] English} |
| 72 |
\typeout{[2] Portuguese} |
| 73 |
\typeout{[3] Spanish} |
| 74 |
\typeout{[4] French} |
| 75 |
\typeout{[5] French (Swiss)} |
| 76 |
\typeout{[6] French (Belgium)} |
| 77 |
\typeout{[7] German} |
| 78 |
\typeout{[8] Italian} |
| 79 |
|
| 80 |
\typein[\response]{} |
| 81 |
|
| 82 |
\ifcsundef{setlang\response}% |
| 83 |
{% |
| 84 |
\typeout{Invalid response '\response', please select a number from 1 to 8}% |
| 85 |
\langid=-1\relax |
| 86 |
}% |
| 87 |
{\uselangopt{\response}} |
| 88 |
|
| 89 |
\ifnum\langid=-1 |
| 90 |
\repeat |
| 91 |
|
| 92 |
\ifcase\langid |
| 93 |
\or \selectlanguage{english} |
| 94 |
Current language: English. |
| 95 |
\or \selectlanguage{portuges} |
| 96 |
Current language: Portuguese. |
| 97 |
\or \selectlanguage{spanish} |
| 98 |
Current language: Spanish. |
| 99 |
\or \selectlanguage{french} |
| 100 |
Current language: French. |
| 101 |
\or \selectlanguage{french} |
| 102 |
Current language: French (Swiss). |
| 103 |
\or \selectlanguage{french} |
| 104 |
Current language: French (Belgium). |
| 105 |
\or \selectlanguage{ngerman} |
| 106 |
Current language: German. |
| 107 |
\or \selectlanguage{italian} |
| 108 |
Current language: Italian. |
| 109 |
\fi |
| 110 |
|
| 111 |
\def\startval{-1} |
| 112 |
|
| 113 |
\loop |
| 114 |
\typein[\startval]{Start value? (Integer from 0 to 99999) [Default 1]} |
| 115 |
\ifdefempty{\startval}{\def\startval{1}}{} |
| 116 |
\ifnum\startval<0\def\startval{-1}\fi |
| 117 |
\ifnum\startval>99999\def\startval{-1}\fi |
| 118 |
|
| 119 |
\ifnum\startval=-1 |
| 120 |
\repeat |
| 121 |
|
| 122 |
\def\endval{-1} |
| 123 |
|
| 124 |
\loop |
| 125 |
\typein[\endval]{End value? (Integer from 0 to 99999) [Default 1000]} |
| 126 |
\ifdefempty{\endval}{\def\endval{1000}}{} |
| 127 |
\ifnum\endval<0\def\endval{-1}\fi |
| 128 |
\ifnum\endval>99999\def\endval{-1}\fi |
| 129 |
\ifnum\endval=-1 |
| 130 |
\repeat |
| 131 |
|
| 132 |
\def\stepsize{0} |
| 133 |
|
| 134 |
\loop |
| 135 |
\typein[\stepsize]{Step size? (Non zero integer) [Default 1]} |
| 136 |
\ifdefempty{\stepsize}{\def\stepsize{1}}{} |
| 137 |
\ifnum\stepsize=0 |
| 138 |
\repeat |
| 139 |
|
| 140 |
\typeout{From {\startval} to {\endval} step {\stepsize}} |
| 141 |
|
| 142 |
\ifnum\startval<\endval\relax |
| 143 |
\ifnum\stepsize<0\relax |
| 144 |
\PackageError{fc-lang}{Infinite loop not permitted!}{} |
| 145 |
\def\endval{\startval} |
| 146 |
\fi |
| 147 |
\fi |
| 148 |
|
| 149 |
\ifnum\startval>\endval\relax |
| 150 |
\ifnum\stepsize>0\relax |
| 151 |
\PackageError{fc-lang}{Infinite loop not permitted!}{} |
| 152 |
\def\endval{\startval} |
| 153 |
\fi |
| 154 |
\fi |
| 155 |
|
| 156 |
\newcount\numformat |
| 157 |
|
| 158 |
\numformat=-1 |
| 159 |
\loop |
| 160 |
\typeout{Which format?^^J} |
| 161 |
\typeout{[1] ordinalstring} |
| 162 |
\typeout{[2] Ordinalstring} |
| 163 |
\typeout{[3] ORDINALstring} |
| 164 |
\typeout{[4] numberstring} |
| 165 |
\typeout{[5] Numberstring} |
| 166 |
\typeout{[6] NUMBERstring} |
| 167 |
|
| 168 |
\typein[\response]{Default: 1} |
| 169 |
|
| 170 |
\ifcsundef{setformat\response}% |
| 171 |
{% |
| 172 |
\numformat=-1\relax |
| 173 |
\typeout{Invalid response '\response', please select a number from 1 to 6}% |
| 174 |
}% |
| 175 |
{% |
| 176 |
\useformat\response |
| 177 |
} |
| 178 |
|
| 179 |
\ifnum\numformat=-1 |
| 180 |
\repeat |
| 181 |
|
| 182 |
\ifcase\numformat |
| 183 |
\or\def\stringtype{ordinalstring} |
| 184 |
\or\def\stringtype{Ordinalstring} |
| 185 |
\or\def\stringtype{ORDINALstring} |
| 186 |
\or\def\stringtype{numberstring} |
| 187 |
\or\def\stringtype{Numberstring} |
| 188 |
\or\def\stringtype{NUMBERstring} |
| 189 |
\fi |
| 190 |
|
| 191 |
\ifnum\langid>3\relax |
| 192 |
\ifnum\langid<7\relax |
| 193 |
\myctr=-1\relax |
| 194 |
\loop |
| 195 |
\typeout{Ordinal type?^^J} |
| 196 |
\typeout{[1] eme} |
| 197 |
\typeout{[2] e} |
| 198 |
\typein[\response]{Default: 1} |
| 199 |
\ifdefempty{\response}% |
| 200 |
{% |
| 201 |
\def\response{1}% default |
| 202 |
\myctr=1\relax |
| 203 |
}% |
| 204 |
{% |
| 205 |
\ifdefstring{\response}{1}% |
| 206 |
{% |
| 207 |
\fmtcountsetoptions{abbrv=false}\myctr=1\relax |
| 208 |
}% |
| 209 |
{% |
| 210 |
\ifdefstring{\response}{2}% |
| 211 |
{% |
| 212 |
\fmtcountsetoptions{abbrv}\myctr=2\relax |
| 213 |
}% |
| 214 |
{% |
| 215 |
\myctr=-1\relax |
| 216 |
\typeout{Invalid response '\response', please select a |
| 217 |
number from 1 to 2}% |
| 218 |
}% |
| 219 |
}% |
| 220 |
}% |
| 221 |
\ifnum\myctr=-1 |
| 222 |
\repeat |
| 223 |
\fi |
| 224 |
\fi |
| 225 |
|
| 226 |
\myctr=-1 |
| 227 |
\loop |
| 228 |
\typeout{Ordinal format?^^J} |
| 229 |
\typeout{[1] raised} |
| 230 |
\typeout{[2] level} |
| 231 |
\typein[\response]{Default: 1} |
| 232 |
\ifdefempty{\response}{\def\response{1}}{}% |
| 233 |
|
| 234 |
\ifdefstring{\response}{1} |
| 235 |
{% |
| 236 |
\fmtcountsetoptions{fmtord=raise}\myctr=1\relax |
| 237 |
}% |
| 238 |
{% |
| 239 |
\ifdefstring{\response}{2} |
| 240 |
{% |
| 241 |
\fmtcountsetoptions{fmtord=level}\myctr=2\relax |
| 242 |
}% |
| 243 |
{% |
| 244 |
\myctr=-1\relax |
| 245 |
\typeout{Invalid response '\response', please select a |
| 246 |
number from 1 to 2}% |
| 247 |
}% |
| 248 |
} |
| 249 |
|
| 250 |
\ifnum\myctr=-1 |
| 251 |
\repeat |
| 252 |
|
| 253 |
\ifnum\langid=1\relax |
| 254 |
\myctr=1\relax |
| 255 |
\else |
| 256 |
|
| 257 |
\ifboolexpr |
| 258 |
{ |
| 259 |
test {\ifnumequal{\langid}{7}} |
| 260 |
and |
| 261 |
test {\ifnumgreater{\numformat}{3}} |
| 262 |
}% |
| 263 |
{% |
| 264 |
\loop |
| 265 |
\ifnum\langid=7\relax |
| 266 |
\typein[\response]{Gender? (m, f or n) [Default: m]} |
| 267 |
\ifcsundef{setgender\response}% |
| 268 |
{% |
| 269 |
\typeout{Invalid response '\response', please select a |
| 270 |
number from 1 to 3}% |
| 271 |
\myctr=-1\relax |
| 272 |
}% |
| 273 |
{\usegender\response} |
| 274 |
\else |
| 275 |
\typein[\response]{Gender? (m or f) [Default: m]} |
| 276 |
\ifcsundef{setgender\response}% |
| 277 |
{% |
| 278 |
\typeout{Invalid response '\response', please select a |
| 279 |
number from 1 to 2}% |
| 280 |
\myctr=-1\relax |
| 281 |
}% |
| 282 |
{% |
| 283 |
\ifdefstring{\response}{3} |
| 284 |
{% |
| 285 |
\typeout{Invalid response '\response', please select a |
| 286 |
number from 1 to 2}% |
| 287 |
\myctr=-1\relax |
| 288 |
} |
| 289 |
{% |
| 290 |
\usegender\response |
| 291 |
} |
| 292 |
} |
| 293 |
\fi |
| 294 |
\ifnum\myctr=-1 |
| 295 |
\repeat |
| 296 |
}% |
| 297 |
{% |
| 298 |
} |
| 299 |
|
| 300 |
\fi |
| 301 |
|
| 302 |
\ifcase\myctr |
| 303 |
\or \def\gender{m} |
| 304 |
\or \def\gender{f} |
| 305 |
\or \def\gender{n} |
| 306 |
\fi |
| 307 |
|
| 308 |
\ifnum\langid=7 |
| 309 |
\ifnum\startval>99 |
| 310 |
\myctr=-1 |
| 311 |
\loop |
| 312 |
\typeout{einhundert/eintausend or hundert/tausend?^^J} |
| 313 |
\typeout{[1] einhundert/eintausend} |
| 314 |
\typeout{[2] hundert/tausend} |
| 315 |
\typein[\response]{Default: 1} |
| 316 |
\ifthenelse{\equal{\response}{}}{\def\response{1}}{}%default |
| 317 |
\ifthenelse{\equal{\response}{1}}{% |
| 318 |
\renewcommand{\einhundert}{einhundert} |
| 319 |
\renewcommand{\eintausend}{eintausend} |
| 320 |
\myctr=1}{% |
| 321 |
\ifthenelse{\equal{\response}{2}}{% |
| 322 |
\renewcommand{\einhundert}{hundert} |
| 323 |
\renewcommand{\eintausend}{tausend} |
| 324 |
\myctr=2}{% |
| 325 |
\myctr=-1}} |
| 326 |
\ifnum\myctr=-1 |
| 327 |
\repeat |
| 328 |
\fi |
| 329 |
\fi |
| 330 |
|
| 331 |
\setcounter{startval}{\startval} |
| 332 |
\setcounter{endval}{\endval} |
| 333 |
\setcounter{stepsize}{\stepsize} |
| 334 |
|
| 335 |
\stepcounter{endval} |
| 336 |
\begin{ttfamily} |
| 337 |
\noindent |
| 338 |
\makebox[0.25in][c]{N} |
| 339 |
\makebox[0.5in][c]{ordinal}\quad |
| 340 |
\stringtype |
| 341 |
\par |
| 342 |
\myctr=\value{startval} |
| 343 |
\loop |
| 344 |
\noindent |
| 345 |
\setcounter{N}{\myctr} |
| 346 |
\makebox[0.25in][r]{\arabic{N}} |
| 347 |
\makebox[0.5in][r]{\ordinal{N}[\gender]}\quad |
| 348 |
\csname\stringtype\endcsname{N}[\gender]. |
| 349 |
\par |
| 350 |
\advance\myctr by \value{stepsize}\relax |
| 351 |
\ifnum\myctr<\value{endval} |
| 352 |
\repeat |
| 353 |
|
| 354 |
\end{ttfamily} |
| 355 |
|
| 356 |
\end{document} |