OK, I think I understand what is happening to you now. Since you are still trying to configure an action without having run the chain, the value of pagenum is an empty string (chain variables are only assigned at runtime, even without the runtime option ticked).
So, at this point in time, the value of pagenum (empty string) cannot be used in mathematical operations, and the template evaluator will return an error and you will not be able to save it. To remedy this:
Code:
program:
pagenum = ifempty(globals(pagenum), 1)
pagenum = globals(pagenum=1)
This will give the evaluator a valid default, and the template should be accepted. You can use any numerical value, except ZERO, as you are using it as the denominator.