Darc,
Is this something that you cannot handle with an M98?
MyVariable = (MyVariable-1)
That would be the barest example. I'm not sure if Camsoft will permit an If Then loop in a gcode program.
That's why I'd recommend that you use the M98, as that is what it does best is count down