MC is used for continuous motion. Below is a sample program.
The D4000 command sets the direction based on the sign of the numeric value; a D-4000 would set the direction as negative. The numeric value itself is irrelevant in MC, only the sign is important.
To stop on an input condition, first initiate motion and then LOOP another subprogram that does nothing but check for the inputs.
In order to be able to use the TR command after motion has been commanded change the setting of the CQ system variable. Setting the CQ to 0 will allow the processor to command motion and then execute subsequent commands like TR. This is similar to setting COMEXC1 in the 6K/6000 language.