Cutter comp on own line

Desired output, created in CQR_THRMWOOD_3X for Paul Downs Cabinetmakers. This works between contours in a single path as well:

G90
G00 X110.0701 Y51.6648
G41
G01 Z-0.625 F100.
G02 X110.0625 Y51.7516 I0.4924 J0.0868
G01 Y51.9375
G01 X110.2524
G02 X110.3392 Y51.9299 I0. J-0.5
G00 Z0.3
G40

This can probably be refined and made cleaner, but it does work. cc_1013$ must be defined = 1

cc_1013$     : 1     #calculate cc_pos$ with cutter comp value on 1013 line 1=yes$
sav_cc_pos  : 0
compon      : -1
compdir     : 0 
cc_pos_out  : 0

pccdia          #Cutter Compensation
      #Force Dxx#
      
      #if prv_cc_pos$ <> cc_pos$ & cc_pos$, prv_tloffno$ = c9k
      if cc_pos$ & not(sav_cc_pos) & compon = -1, 
        [
        compon     = 1        #comp is on, will come out when ready
        compdir    = cc_pos$  #save comp direction for later
        #sav_cc_pos = cc_pos$  #save comp direction for later
        ]
      if not(cc_pos$) & sav_cc_pos & compon = -1, 
        [
        compon     = 0      #comp is off, will come out when ready
        #sav_cc_pos = cc_pos$
        ]
      #"!!!", ~sav_cc_pos, ~cc_pos$, ~prv_cc_pos$, ~cc_pos_out, ~gcode$, ~compon, ~cstart$, ~cend$, "!!!"
      if (compon = 1)
        | (compon = 0 & gcode$ = 0), 
        [
        if compon = 1, cc_pos_out = compdir
        if compon = 0, cc_pos_out = 0    
        sccomp
        sav_cc_pos = cc_pos_out
        compon = -1
        ]
      if cc_pos$, !tloffno$