Yodl has four macros to modify and/or to set the values of counters. The macros are:
COUNTERVALUE(somecounter)
: This macro expands to the value of
somecounter. E.g., if the current value is 2, then the macro writes 2
on the output file.
SETCOUNTER(somecounter)(number)
: This macro sets the value of
somecounter to the value of number. The second parameter list must
be an integer number (i.e., consisting of the characters 0
to 9
,
optionally prefixed by a -
sign). The macro does not expand to
anything; i.e., it does not write to the output file.
ADDTOCOUNTER(somecounter)(number)
: This macro adds the value of
number to somecounter. The number may be negative.
USECOUNTER(somecounter)
: This macro first increases the value of
somecounter by 1, and then writes the value of the counter to the
output file.
This command is particularly useful in combination with NEWCOUNTER
:
since NEWCOUNTER
initializes a counter to zero, USECOUNTER
can be
used to increase the value and to output it. The first time that
USECOUNTER
is used on a new counter, the number 1 appears on the
output file. The next time, number 2 appears on the output file etc..
Given the numbering requirements of the hypothetical commands section
and
subsection
(see the previous section), we can now complete the
definitions:
NEWCOUNTER(sectcounter) NEWCOUNTER(subsectcounter) DEFINEMACRO(section)(1)(\ SETCOUNTER(subsectcounter)(0)\ USECOUNTER(sectcounter) ARG1) DEFINEMACRO(subsection)(1)(\ COUNTERVALUE(sectcounter).USECOUNTER(subsectcounter) ARG1)
Please send Yodl questions and comments to yodl@icce.rug.nl.
Please send comments on these web pages to (address unknown)
Copyright (c) 1997, 1998, 1999 Karel Kubat and Jan Nieuwenhuizen.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.