User-defined counters

Navigation:  More Advanced Procedures > Using Variables > Counter variables for numbering >

User-defined counters

Previous pageReturn to chapter overviewNext page

Show/Hide Hidden Text

You can define as many user counter variables as you like and you can define the starting number to be used for each variable, which makes it possible to use the variables across multiple projects. User-defined counter variables cannot be referenced. They simply provide consecutive automatic numbering, with no additional functionality.

 

flag_green        Key Information

If you use a counter variable inside topic or image captions you must only use it in topic or image captions. If you also use it in normal topic text the numbering will be wrong. (Variables in captions are evaluated in a separate pass when you publish.)

Click to expand/collapseRestrictions of user-defined counter variables

User-defined variables are quite simple. They will provide you with continuous numbering but that is all. You cannot "refer" to them with variables in references like "See Figure XX". See Figure and table counters for instructions on how to create referencing counters for figures and tables.

Click to expand/collapseHow to define user counter variables

User counter variables are identified by two ++ characters at the end of the variable name. Otherwise counter variables can have any name you like, just like normal user-defined variables.

Every time Help & Manual encounters the variable in a project it increases its value by 1. This means if you want to start with 1 you  must enter "0" as the variable's initial value when you define it. If you want to start with 10 you must enter "9" and so on (without the quotes).

1.Define a text variable with two + characters at the end of its name, for example ITEM++, VIEW++ and so on.

2.Set the value of the variable to 0 if you want to start counting at 1, to 89 if you want to start counting with 90 and so on. (Always one less than the number you want to use, the value is always incremented whenever the variable is used.)

Click to expand/collapseHow to use counter variables

Just insert the variable in the place where you want the count to be displayed. Each time you use the same variable the variable's last value will be increased by 1. For example, to number your images just type the counter variable in the image caption field of the Insert Image dialog with appropriate text, for example

dlg_countvars
 The Insert Image dialog (select Write > Insert > Image, or double-click an existing image to display)

User variables in image captions:

User-defined variables cannot be referenced. Use the special figure and table counter variables for creating numbered figures and tables that you can reference in other places in your text.

If you do use user counter variables in image captions it's important to know that they are evaluated in a separate pass when you publish. This means that if you use a counter variable in an image caption you must never use the same variable anywhere else in the current project. You can only use that variable in image captions. If you also use the variable in other locations the count will be incorrect.

Click to expand/collapseUsing counter variables in modular projects

You can use these variables in modular projects. You just need to reset the starting value of the variables in your child projects if you are using runtime merging in HTML Help.

Publish time merging:

If you are using publish time merging you just need to define the variable in the master project and then use it throughout all your projects. Publish time merging is the only available option for all formats except HTML Help. In HTML Help you can choose either publish time merging or runtime merging,

Runtime merging in HTML Help:

If you are using runtime merging for your HTML Help output you must define the correct starting values for each variable in the child projects. To do this you need to check the final value in the preceding project and set the starting value to that value.

For example, if the final value of your IMAGENO++ variable in Project A is 63 you need to define the value of IMAGENO++ in Project B as 63. Then the value will be incremented correctly to 64 the first time you use the variable in Project B.

See also:

Working with Modular Help Systems