here is another simple code to do tool change:
Sub Main()
NumSlots=8
OldTurretPos=(GetOEMDRO(803))
OldToolSlot=Abs(GetOEMDRO(803)*

NextTool = GetSelectedTool()
NextToolSlot = (NextTool-1)*360/NumSlots
If OldToolSlot = NextToolSlot Then
SetCurrentTool(NextTool)
Exit Sub
End If
If NextTool>8 Or NextTool<1 Then
Message("Next Tool out of range")
Exit Sub
End If
MoveDis = (NextToolSlot-OldTurretPos)
If Abs(MoveDis) >180 Then
If MoveDis < 0 Then
MoveDis = 360 - MoveDis
Else
MoveDis = MoveDis + 360
End If
End If
ActivateSignal(OUTPUT3) 'Release Turret holding pin
Code "G4 P0.5"
While IsMoving ()
Wend
Code "G00 G91 a" & MoveDis
While IsMoving ()
Wend
DeActivateSignal(OUTPUT3) 'Engage Turret holding pin
SetCurrentTool(NextTool)
Code "G90"
End Sub
Output 3 is what ever you use to engage/disengage turret lock.
803 is the oem code for the a axis.
set the a axis to angular on the General config page
check auto tool change