c# - Which program converts sequential code into loop code? -


example sequential code:

console.writeline("hello"); sleep(20); console.writeline("end");   

example loop code(function being looped):

bool step2 = false; bool step3 = false; bool beginn = true; int = 0;  void looped() //each second {   if (beginn == true)   {     console.writeline("hello");     beginn = false;     step2 = true;   }   if (step2 == true)   {     if (i <= 20)     {       i++;     }     else     {       step2 = false;       step3 = true;     }   }   if (step3 == true)   {     console.writeline("end");     step3 = false;   } } 

which program converts sequential code loop code? want use unity, c#/mono or javascript output desired.

in general, right terms each kind of coding?

since unity, think you're looking coroutines , yield waitforseconds() paradigm: http://docs.unity3d.com/documentation/scriptreference/index.coroutines_26_yield.html

void begin() {     startcoroutine("looped"); }  ienumerator looped() //each second {     console.writeline("hello");     yield return new waitforseconds(20);     console.writeline("end"); } 

edit: javascript version:

looped();  function looped() {     print("hello");     yield waitforseconds(20);     print("end"); } 

edit: if intended called update method, need use startcoroutine method start looped.

c#:

void update() {     startcoroutine("looped"); }  ienumerator looped() //each second {     console.writeline("hello");     yield return new waitforseconds(20);     console.writeline("end"); } 

javascript:

function update() {     startcoroutine("looped") }  function looped() {     print("hello");     yield waitforseconds(20);     print("end"); } 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -