Sub Main()'M800.m1s Bar Stock Feeder'OUTPUT5 is open collet, OUTPUT6 is close collet, INPUT4 Barstop signalDim StopPositionX, StopPositionZStopPositionX=4      'Stop location in X axis in machine coordinatesStopPositionZ=4      'Stop location in Z axis in machine coordinatesCode "M5"   'Stop SpindleCode "G0 G53 X" & StopPositionX & " Z" & StopPositionZWhile IsMoving()WendActivateSignal(OUTPUT5)   'Open colletCode "G4 p2"         '2 second pause give stock time to move forwardWhile IsMoving()      'Give more or less seconds depending feed forward timeWend               'I didnt use a wait for or a while statement so not to tie you your processor.If Not(IsActive(INPUT4)) ThenMessage("Out of Stock")Exit SubEnd IfdeActivateSignal(OUTPUT5)   'Close colletCode "G4 p1"         '1 second pause gives collet time to clampWhile IsMoving()      'Give more or less seconds depending on closure time.WendEnd Sub 