Today I want to share my knowledge of CNC machines of parameter 6700&6710. Feel free to discuss with me if you have a better solution.

counting parts on FANUC control with custom"M" code.

(1)change parameter6700#bit0-"1"
(2)leaving parameter 6700#bit0 to "0".M30 M02 and customM code will count.
(3)short and sweet system variables ,add#3901=#3901+1 anywhere one should choose in the program,much alike the 1st method.

Above is my personal preference.Feel free to discuss with me if you have a better solution.