
ToolNum = GetDRO (24)
ZShift = -1.4368
Offset = GetOEMDRO(49)

'Tool_Num = Question("What Tool Height Register???")

If ToolNum <>0 Then

    ActivateSignal(Output3) 'hood up
    Code "G4 P1.0"    'Wait for the hood to rise
    
        CodeSingle("G90 G00 G53 Z0") 'move spindle to .1 below z home
	CodeSingle("G53 G00 X+0.4186 Y+104.725")'move into switch position

	CodeSingle("G91 G31 Z-12 F25")
	
	CodeSingle("G90")
		Zpos = GetVar(2002)
		
	CodeSingle("G91 Z+1 F100")
	CodeSingle("G91 G31 Z-1.25 F25")
	
	CodeSingle("G90")
	ZposC = GetVar(2002)
	
	If Zpos - ZposC = > .002 Then
		MsgBox("Check switch - " & Zpos - ZposC & "measurement error)
	End If
	
	If Zpos - ZposC = < -.002 Then
		MsgBox("Check switch - " & Zpos - ZposC & "measurement error)
	End If
	
	
	'MsgBox("Z Position == " & Zpos)
	'SetDRO(24,Tool_Num)
	Tool_Offset = Zpos
	Call setOEMDRO(42, Tool_Offset + ZShift+Offset)
	sleep(200)
	SetDRO(24,ToolNum)

	codeSingle("G4 P.1")
	CodeSingle("G53 G0 Z0.0")
	
	DeActivateSignal(Output3) 'lower hood
    Code "G4 P1.0"    'Wait for the hood down
    CodeSingle("G53 G00 X+6") 'move to clear switch for next move

End If

