Changes

Jump to navigation Jump to search
m
=== Scratch registers ===
Because values often values need to be saved only temporarily, ConTeXt defines the <''counter''> <code>\scratchcounter</code>. This is a real <''counter''>, and not a pseudo one, as we will meet further on. Analogous scratch registers are <code>\scratchdimen</code>, <code>\scratchskip</code>, <code>\scratchmuskip</code>, <code>\scratchtoks</code> and <code>\scratchbox</code>. You can use these registers in your own macro code, but a warning is in order:
Do '''not''' expect it to be save safe to use any of the scratch registers across any call to any internal ConTeXt macro. While ConTeXt is supposed to make sure that the scratch registers it needs are initialized on entry to the internal macro, it doesn't bother to restore the original value when it returns from that macro, so you never know what will be in any scratch register afterwards.
ConTeXt uses a rather large collection of other scratch registers itself. Their names all look like this: <code>\!!XXXXXY</code>, where <code>XXXXX</code> is something like 'count' or 'depth', and <code>Y</code> is a letter starting from <code>a</code> (e.g. <code>\!!counta</code>). The fact that their names start with <code>!!</code> is a clear statement: Don't touch them, it's dangerous. If you need extra scratch registers, define your own.

Navigation menu