main() { do { do{ a=gvarget(6065); }while(a!=0); //wait Motion Controller ready to accept new program gvarset(100001,1); //Reset G-code pointer to start timer=5; do{ timer--;}while(timer>0); //0.5 sec Pause gvarset(100002,1); //Start G-code }while(gvarget(400)==0); //endless loop, if #400==0, otherwise exit from procedure exit(99); }; //If variable #400 will be set to non-zero value, NOT_ENDLESS.plc process will be finished