（平面 + 矩形　加工プログラム)

XW=40.(X-WIDTH)
YW=40.(Y-WIDTH)
ZRP=5.(R-POINT)
ZS=2.(Z-START)
FFSE=0(OFFSET)

G15H1
T10M6(FACE MILL)
TD=100(TOOL-D100)
SPIN=318*100/TD(SPINDL SPEED)
FEED=5*0.1*SPIN(FEED)
G90G00X0Y0
G56Z100.HA
M01
S=SPIN M3
G00Z=ZRP(R-POINT)

ZPIC=-1.5(Z-PICH)
ZE=0(Z-END)
STEP=1(STEP)

NA1(CYCLE CUT)
ZZ=ZS+ZPIC*STEP
IF[ZZ LE ZE] NA2(FINAL CUT)
X=XW/2+TD/2+5. Y=0
G01Z=ZZ F=FEED/4
X=-[XW/2+TD/2+5.] F=FEED
G00Z=ZS(Z-DEPTH)
STEP=STEP+1(STEP++)
GOTO NA1(CYCLE CUT)

NA2(FINAL CUT)
IF [ZZ EQ ZE] NEXT1(NEXT)
X=XW/2+TD/2+5. Y=0
G01Z=ZE F=FEED/4
G01X=-[XW/2+TD/2+5.] F=FEED
G00Z=ZS(Z-DEPTH)

NEXT1(NEXT)
G00Z5.

T5M6(R-MILL)
TD=18.(TOOL-D18)
SPIN=318*20/TD(SPINDL SPEED)
FEED=4*0.1*SPIN(FEED)
G90G00X0Y0
G56Z100.HA
M01
S=SPIN M3
G00Z=ZRP M8(R-POINT)

N01(CYCLE CUT)
ZPIC=-2.5(Z-PICH)
ZE=-12.8(Z-END)
CALL OSUB1 ZS=ZS ZE=ZE TD=TD XW=XW YW=YW ZPIC=ZPIC FFSE=FFSE FEED=FEED

T6M6(F-MILL)
TD=20.(TOOL-D20)
SPIN=318*40/TD(SPINDL SPEED)
FEED=2*0.05*SPIN(FEED)
G90G00X0Y0
G56Z100.0HA
M01
S=SPIN M3
G00Z=ZRP(R-POINT)

N02(CYCLE CUT)
ZPIC=-13.(Z-PICH)
ZE=-13.(Z-END)
CALL OSUB1 ZS=ZS ZE=ZE TD=TD XW=XW YW=YW ZPIC=ZPIC FFSE=FFSE FEED=F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