A couple ways but this can also depend on the machine builder with control interface as to what will work. If you have a FANUC control or one that uses FANUC type commands, then you can do a sub call routine and have a counter running.
Sub program routines use M98 (if you have this ability on the laser). In the subroutine, you keep the cutting portion there and basically the main program can simply reposition for the next cut and/or finish depending on the count. To do this, the sub call code may use something like this:
M98 = sub call
P = the called program for the cut. value above breaks down as:
"020" = run 20 times (most controls will allow up to 999)
"1001" = the actual sub program called for the cut.
Now again, this depends on your control function and I've also seen some lasers use a different command (m code) for sub calls.
Another way is to use a macro counter (if you have macro cabability). You can then set the counter inside this program to count the cycles, then end the program when you reach it:
To break down the macro:
IF = sets up the conditional statement
[#100LE20.] = #100 is the macro variable to store the count. Any # will work but for something like this, I generally use the 100s or the 500s. Be sure not to use a variable that the machine already uses for other logic.
LE = meaing "Less than or equal to"
20. = the number of cuts/parts/cycle. You adjust this number for the count.
GOTO100 = same as you used it previously.
Just make sure on the next cycle of material, you reset the variable back to "0" for the counter. Or a "1" in this case depending on the number you want to count from. You can reset the variable manually by going to your Macro Variables page or reset the value in the program at the top or something for the initial cycle start by inserting a line: #100 = 1.