Changes

Jump to navigation Jump to search
some restructuring and cleanup
\savecounter [page]
\restorecounter [page]
%\getcounter [page] \rawcountervalue [page]
</texcode>
 
== Names of Commonly Used Counters ==
 
* <code>userpage</code> for visible pagenumbers
* <code>page</code> for internal pagenumbers
* <code>formula</code> for formula numbers
* <code>table</code> for table numbers
* <code>figure</code> for figure numbers
 
 
== Testing the Value of a Counter ==
 
If you need to test the value of a counter, use \rawcountervalue, not \getcounter:
 
<context source="yes" text="results in:">
\definecounter[mynumber][]
\setcounter[mynumber][42]
\doifelse{\getcounter[mynumber]}{42}{
Strange, \type{\getcounter} worked.
}{
Using \type{\getcounter} does not work.
}
 
\doifelse{\rawcountervalue[mynumber]}{42}{
Ok, the test with \type{\rawcountervalue} worked.
}{
Strange, \type{\rawcountervalue} failed.
}
</context>
 
In LMTX, {{cmd|getcounter}} seems to be generally defunct.
== Coupling Counters ==
Default value of counter one: \getcounterrawcountervalue[one]
We increment counter two
\incrementcounter[two]
New value of counter one: \getcounterrawcountervalue[one]
</context>
By default counters are reset with each new chapter. To have a counter which isn’t reset one needs “wayyou need `way=bytext" `, and to remove the chapter number from the \getcounter result one has you have to add “prefix`prefix=no”no`.
An example Example definition is:
<texcode>
\definecounter[examplecounter][way=bytext,prefix=no]
</texcode>
== Testing Outdated information == === Forcing the Value Reset of a Counter ==If you need to test the value of a counter, use \rawcountervalue, not \getcounter:<texcode>\definecounter[mynumber][]\setcounter[mynumber][42]\doifelse{\getcounter[mynumber]}{42}{ Strange, \type{\getcounter} worked.}{ Using \type{\getcounter} does not work.}=
\doifelse{\rawcountervalueIn [mynumberhttp://www.mail-archive.com/ntg-context%40ntg.nl/msg78847.html 2015]}{42}{ Ok, the test with \type{\rawcountervalue} workedthere was a bug that counters were reset (by chapter, page, etc.}{ Strange, \type{\rawcountervalue} failed) only when they were incremented.}</texcode>
== Forcing the Reset of a Counter ==
Due to a current bug [http://www.mail-archive.com/ntg-context%40ntg.nl/msg78847.html], counters are reset by chapter, page, etc. only when they are incremented.
To force the reset, you can increment and then decrement a counter before using it.
<texcode>
</texcode>
=== \definenumber or \definecounter ? ===
{{cmd|definenumber}} etc. are obsolete aliases for {{cmd|definecounter}} etc.
 
== Names of Commonly Used Counters ==
 
* <code>userpage</code> for visible pagenumbers
* <code>page</code> for internal pagenumbers
* <code>formula</code> for formula numbers
* <code>table</code> for table numbers
* <code>figure</code> for figure numbers
[[Category:Programming and Databases]]
[[Category:Tools]]

Navigation menu