AJ123 Posted March 28, 2012 Share Posted March 28, 2012 I was wondering if it is possible to write in a one sequence a pause statement so that another sequence that is running will pause. Ex. Sequence 1 While (1) Pump = 0 delay(5) Pump = 1 delay(30)endwhile (1)[/CODE]sequence 2[CODE]Pump2 = 0 delay(30)Pump2 = 1[/CODE]and what i would want to do is write in sequence 2 to pause the loop function of sequence 1 where it is at and then run sequence 2 then when sequence 2 is done continue sequence 1 where it left off. Link to comment Share on other sites More sharing options...
AzeoTech Posted March 28, 2012 Share Posted March 28, 2012 There isn't a built in way to do this. But it'd be pretty easy to do in script. Just add a pause flag and waitfor()'s: global sequence1_pause = 0while(1) pump = 0 delay(5) waitfor(sequence1_pause == 0, 0.1) pump = 1 delay(30) waitfor(sequence1_pause == 0, 0.1)endwhile[/CODE]Its not quite the same as a true pause, but close. By setting sequence1_pause to 1, sequence 1 will stop just before the next change of the pump. Setting it to 0 will resume it and change the pump immediately (provided the delay() finished).If you really wanted it to pause in the middle of the delay() you'd have to script it differently, probably something like this:[CODE]global sequence1_pause = 0private nexttimewhile(1) pump = 0 nexttime = systime() + 5 while((systime() < nexttime) || (sequence1_pause)) delay(0.1) if (sequence1_pause == 1) nexttime += 0.1 endif endwhile pump = 1 nexttime = systime() + 30 while((systime() < nexttime) || (sequence1_pause)) delay(0.1) if (sequence1_pause == 1) nexttime += 0.1 endif endwhileendwhile[/CODE] Link to comment Share on other sites More sharing options...
AJ123 Posted March 28, 2012 Author Share Posted March 28, 2012 I am missing where that fits into my second sequence. I would want to write the waitfor script into my second sequence at the beginning? I am missing how they come togther. Because I want sequence one to pause while sequence two is going then unpause when sequence two has finished. I don't see sequence two and am missing something i guess. Link to comment Share on other sites More sharing options...
AzeoTech Posted March 28, 2012 Share Posted March 28, 2012 All the script above was for sequence 1 (the one you want to pause). Its two different ways of doing it depending on how precise the pause point should be. To pause the sequence, simply set sequence1_pause to 1 in sequence 2 (or wherever you want), something like: sequence1_pause = 1 then to start it back up: sequence1_pause = 0 Link to comment Share on other sites More sharing options...
AJ123 Posted March 29, 2012 Author Share Posted March 29, 2012 Oh ok I got it working now thank you very much for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.