Thanks. Both methods are far more elegant then the hack I've been working on. The difficulty with both is that I want to be able to change the counter value using the set message (eg set 5) and for it to proceed counting down and then up.
you can either use plain math (% 16), (!- 16), or you can use 2 independent counters.
for me the latter seems for be simpler when you want to switch counting modes
during play, and also for a "reset" function.
Panaiotis's autocount object has 'updown' and 'downup' counting modes, as well as various others. You can find it here: http://www.unm.edu/~panaioti/Max/ObjMenu.htm
Below is an 'autocountoid' abstraction that I made when autocount was not UB, and which also has an 'uppdownn' mode, ie. repeating the max and min before changing direction, which is useful for arpeggiators etc.
Iirc, the arguments are count mode, initial value, min, max, step and ms between ticks,