Here is the macro file
Option Explicit
' This macro iimplements Goto Tool Change logic
Dim x, y, z, CurrMetric
Dim PosIsMetric, DestX, DestY, DestZ
If NOT GetLED (7) AND Not GetLED (8) AND Not GetLED (9) Then ' axes are reffed so Abs coords OK
x = GetUserDRO( 1200 )
y = GetUserDRO( 1201 )
z = GetUserDRO( 1202 )
PosIsMetric = GetUserDRO (1209) ' this is definition of what units the tool change position is in
CurrMetric = GetLed (2)
If (CurrMetric <> 0 And PosIsMetric <> 0) Or (CurrMetric = 0 And PosIsMetric = 0) Then ' we need no conversion
DestX = x
DestY = y
DestZ = z
ElseIf CurrMetric <> 0 and PosIsMetric = 0 Then ' we need to convert to metric
If x <> 9999 Then DestX = x * 25.4
If y <> 9999 Then DestY = y * 25.4
If z <> 9999 Then DestZ = z * 25.4
Else ' convert to imperial
If x <> 9999 Then DestX = x / 25.4
If y <> 9999 Then DestY = y / 25.4
If z <> 9999 Then DestZ = z / 25.4
End If ' got a valid set of destinations
Code "G0" ' to switch things to G0 mode if not there already
If z <> 9999 Then
Code "G53Z" & DestZ
If x <> 9999 And y <> 9999 Then ' can do coordinated move
Code "G53X" & DestX & "Y" & DestY
Else ' do separate move
If x <> 9999 Then Code "G53X" & DestX
If y <> 9999 Then Code"G53Y" & DestY
End If
Else
Message " Z must be moved for safety of X and Y moves but position is 9999"
End If
Else
Message "Cannot use button/M998 as not referenced"
End If
home machine then any tool change does the above