Hi, 
I want to write simple macro for moving Z axis in position for tool change - moving Z+ until switch is triggered.
If switch is not triggered in 200 mm then moving must stop and report an ERROR.
Code:
Code "G01 Z200  F1000" 
Message "Moving on switch for tool change position "
While IsMoving()
If  IsActive(Input2)Then
DooemButton(1003)
Message "Z in position for tool change"
End If
Wend
If Not IsActive(Input2)Then
Message "ERROR - Switch is not triggered"
'Exit Sub
End If 
When I run this code from VB Script Editor works fine but when I call it from Mach3 then after switch is triggered 
I get message "Terminating Script"
I have tray diffrent things (also reinstaling Mach3) and itś always the same.
Any suggestion 

?
Is this  recommended way to stop axis when switch is triggered?
Thanx!