So based on your example by the 4th click the gVariable would equal 7?
If instead it should be 1,2,3,1,2,3 and not 1,3,6,7 then you would use a on click compare event starting with 0.
On-click/compare gVar=0/set gVar 1, gVar=1 set 2, gVar=2 set 3, else gVar>2 set 1.