' Drill G83 X (ignored)  Z (required) Q (required) R (required)' g83 gives C=0 with a full retract to R height' g83.1 gives C=1 with a short retract to the last peck depth' Bug fix for rapid re-entry into hole - Roger Caffin 10/08/2016' Code cleaned up as well       Test = False                  EndX = tEndX()		' this is the X in the G83 call - ignoreEndZ = tEndZ()		' this is the Z in the G83 callQ = ABS(tInFeed())	' Q value, REQUIREDR = tZClear()		' R value, REQUIREDC = tTaper()		' C value =0 (g83) or 1 (g83.1)StartZ = tZStart()	' Starting Z heightRMode = RetractMode()	' I have no idea where this come from (RNC)' I have no idea why you would want this (RNC)' unless you have your Z axis direction upside downIf EndZ< R Then                   Z_Dir = -1                 Else                   Z_Dir = 1                 End IfZClear = .01	' inches clearance for rapid re-entryIf GetLED (2) Then	'if metric  ZClear = ZClear *25.4End If                                Last_Pass = 0		' Flag for reached bottomN = 1			' Prevent run-awaysLast_Depth = R		' Where we got to on the last cycleIf Test = True Then	' Debug log file  OpenTeachFile( "TestIt.tap")          Code "(R= " & R &")"             Code "(X= " & EndX &")"             Code "(Z= " & EndZ &")"             Code "(Q= " & Q &")"             Code "(Dir= " & Dir &")"             Code "(Last_Depth= " & Last_Depth &")"      Code "(Mode is " & C & ")"           End If         Do                                      Code "G00 Z" & Last_Depth	' Rapid down to start ** ADDED - RNC  Next_Z = N * Q *Z_Dir		' Next target depth  If Next_Z <= EndZ Then	' Reached full depth, go no further    Next_Z = EndZ    Last_Pass = 1                                     End If                                  Code "G01 Z" & Next_Z		' Drill next peck distance  If C = 1 Then			' Select retraction mode    Code "G00 Z" & Last_Depth	' G83.1 for fast/partial extract  Else                                      Code "G00 Z" & R		' G83 for full retract  End If  Last_Depth = Next_Z + ZClear	'Start just above last drill depth  N = N + 1            If N = 300 Then Exit DoLoop While (Last_Pass < 1)   If RMode = 1 Then		' And where does RMode come from ????  Code "G00 Z" & StartZ  End If       If Test = True Then                     CloseTeachFile()                     LoadTeachFile()           End If                               