After reading all the posts, still don't quite understand what exactly you're trying to achieve?
Product 1 Force Curve: 3,5,7,2,10,9,,,
Product 2 Force Curve: 9,8,5,3,2,10,,,
Then there it is: D0 stores the data from the force measurement, and the D0 data is constantly changing. The D100 stores the setpoint. D200 stores the maximum. M0 is 1. M1 is the end of the 1 product. M2 is 1 product qualified.
Product 1
if M0=0 then
D200=0
endif
if M0=1 then
if D0>D200 then
D200=D0
endif
endif
if M1=1 then
if D200>D100 then
M2=1
else
M2=0
endif
M0=0
endif