Sub Main()' Dim VariablesDim NumTools As IntegerDim CWStepsPerTool As IntegerDim CCWSteps As IntegerDim HoldingDRO As IntegerDim RequestedTool As IntegerDim CurrentTool As IntegerDim CWFeed As IntegerDim CCWFeed As IntegerDim moves As IntegerDim TotalMove As Integer' set up some varsNumTools = 6CWMovePerTool = 360/NumToolsCCWMove = 10' HoldingDRO = 1050RequestedTool = GetSelectedTool()CurrentTool = GetCurrentTool()CWFeed = 3000CCWFeed = 2000CurrentFeed = GetOEMDRO(818)
Message ""

If IsLoading() Then    Goto EndMarkEnd If' start tool changeMessage ("Requested Tool No=" & RequestedTool)If RequestedTool > NumTools Then	Message "Requested Tool No. too high, program stopped."	Code "M30"	GoTo EndMarkEnd IfIf RequestedTool < 1 Then	Message "Requested Tool No. too low, program stopped."	Code "M30"	GoTo EndMarkEnd IfIf RequestedTool = CurrentTool Then         Message "Requested Tool already loaded"         GoTo EndMarkElse' lets do some changing	If RequestedTool > CurrentTool Then 		moves = RequestedTool - CurrentTool	End If	If RequestedTool < CurrentTool Then 		moves = NumTools - CurrentTool + RequestedTool	End IfTotalMove = (moves * CWMovePerTool)+(CCWMove/2)''''''''''''''''''''''''''''''''''''''' taken this out, you can ensure is safe ' before calling M6'Move to safe position'Code "G0 G53 Z-2 X-2"'Pause for 1/2 second'Code "G04 P0.5"Code "G91 G94" 'incremental & Feed per minuteCode "G01 A" & TotalMove & " F" & CWFeedCode "G01 A-" & CCWMove & " F" & CCWFeed
While IsMoving()	sleep(10)Wend'SetCurrentTool RequestedTool  ' Mach does this'SetUserDRO HoldingDRO, RequestedTool  ' not using thisCode "G90" ' back to absolute movementCode "F" & CurrentFeedEnd IfEndMark:End SubMain' end of tool change    
