OldTool = GetCurrentTool() tool = GetSelectedTool() NewTool = tool MaxToolNum = 6 CurrPos = OldTool Steps = 0 i = 0 While (NewTool > MaxToolNum) NewTool = Question ("Enter New Tool Number up to " & MaxToolNum) Wend If (NewTool = OldTool) And (NewTool > 0) Then Exit Sub End If If (OldTool = 0) Then ActivateSignal(OUTPUT5) ActivateSignal(OUTPUT6) While Not IsActive(INPUT2) Wend CurrPos = 1 SetCurrentTool(CurrPos) If (CurrPos = NewTool) Then DeActivateSignal(OUTPUT6) Sleep(2000) SetCurrentTool(NewTool) Exit Sub End If End If If NewTool > CurrPos Then Steps = NewTool - CurrPos Else Steps = MaxToolNum - CurrPos + NewTool End If Steps = Steps + 1 ActivateSignal(OUTPUT5) ActivateSignal(OUTPUT6) CountPulses: While Not IsActive(INPUT1) Wend i = i + 1 While IsActive(INPUT1) Wend If (i = Steps) Then DeActivateSignal(OUTPUT6) Sleep(5000) SetCurrentTool(NewTool) End End If GoTo CountPulses