Hey Overloaded here is the corrected file, you had an "floating IF in there"
here is the code line with the if that was in your code just sitting there. (I put stars around it so you can see it).
**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
Here is the corrected code, and I change the M5 to dospinstop():
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
DoSpinStop() '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
'scott