hello bob i will begin with the code that you shared
it is messy ... i have written a few tips below + some explanations
about your question, i will open a new thread; pls check it out / kindly
Code:
( original )
N11 V01=1
N112 V01=V01+1
( PROGRAM )
/ IF [ V1 LE ? ] N112
M2
( ? number of parts )
( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
( removing not needed addresses )
( initalizing counter with ZERO instead of ONE )
( replacing V1 with V01; because god of simetry )
( removing bottom comment; way too obvious )
( M02 instead of M2; adding leading zeros, because also V01 is written like that )
(using leading zeros from time to time, means that the mind loses focus when is writing codes )
( is a simple task, so try to make it always the same )
( also, using leading zeros from time to time, affects code simetry; it can not be read fluidly )
V01 = 0
N000 V01 = V01+1
( PROGRAM )
/ IF [ V01 LE ? ] N000
M02 ( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
( replacing ? with variable )
( spaces arround + )
V02 = 30
V01 = 0
N000 V01 = V01 + 1
( PROGRAM )
/ IF [ V01 LE V02 ] N000
M02 ( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
( kitty default : 4 blanks for indentation )
( blank lines insert + '(*)' between V02 and the rest of the code )
( this is intended to separate editable variables from the rest of the code )
V02 = 30
( * )
V01 = 0
N000 V01 = V01 + 1
( PROGRAM )
/ IF [ V01 LE V02 ] N000
M02 ( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
( using / only to toogle counter behaviour may affect other places where / would be required )
( i recomand avoiding / for looping )
( initialize V02 with 0 or 1 )
V02 = 0 or 1
( * )
V01 = 0
N000 V01 = V01 + 1
( PROGRAM )
IF [ V01 LE V02 ] N000
M02 ( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
( is not ok to have the counting line near the begining of the program )
( move it near the end, so to count "executed parts", and not to count "begining of executing" )
V02 = 0 or 1
( * )
V01 = 0
N000 // program
V01 = V01 + 1
IF [ V01 LE V02 ] N000
M02 ( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
( check also this equivalent sample, that does not use explicit conditional and counting codes )
( you achieve same result, with less code )
( you may also use *.sdf files )
CALL OSUB Q30
M02
OSUB
RTS ( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )
( if you wish to use /, so to toogle counting behaviour from cnc panel buttons, thus )
(without editing the code, pls consider that there are some methods )
( they work on newer osps, but maybe also on elder osps can be found some alternatives )
( however, toogling counting behaviour without editing the code seem a bit low-life )
( thus it seems to be an inappropriate solution, for a problem with unknown causes )