The machining program PRO stored in the machining program memory 4 comprises five step programs with top blocks of BLK (n1), BLK (n2), BLK (n3), BLK (n4) and BLK (n5) respectively as shown in FIG. 1, and the types of the steps and tool numbers are assumed to be as follows: