Your choices are timing delay, OR, While Loop.........
Try this code:
'Piston Macro M********* (Label the Macro number instead of *********).
'It wasn't clear, so I am assuming that this is a macro in your running G-code, if it is a button, then paste it in.
'Using SystemWaitFor(), and While Loops, will both suck down, major processor time.
ActivateSignal(OUTPUT8) 'Solinoid to extend cylinder.
Code "G4 P1" 'Pauses for 1 second for cylinder to extend, set pause higher if needed.
While Ismoving() 'Waits for pause to time out.
WEnd
If IsActive(INPUT2) Then 'After 1 second, if INPUT2 (extended limit switch), is active then deactivate cylinder.
DeActivateSignal(OUTPUT8) 'Drop Air cylinder
Else
Question("Did your Cylinder Extend? Check your Air") 'So if INPUT2 don't turn on, and pause times out, error message.
End If
Code "G4 P1" 'Pause 1 second, for cylinder to drop.
While Ismoving() 'Waits for pause to time out.
WEnd
If NOT(IsActive(INPUT3)) then 'If INPUT3 (cylinder back home), is not on/closed, then Error
Question("Did your Cylinder Retract?") 'Error question.
End If
Let me know,
Scott