1 Reply Latest reply on Mar 26, 2017 10:21 AM by pixxxel schubser

    How to come back to the loop 1! …

    Obi-wan Kenobi Adobe Community Professional

      Hi Scripters!

       

      Beginning the run with a = 0, I don't know how to quit the level 4 if the "if" condition is OK with a = 0 and come back to the level 1 to play with a = 1!  

       

      Thanks for your help!

       

      (^/) 

       

      for ( a = 0; a < A; a++ ) {
          // ----------------------------------------------------------------------------------------------------------------------------------
          for ( b = 0; b < B; b++ ) {
              // ----------------------------------------------------------------------------------------------------------------------------------
              for ( var c = 0; c < C; c++ ) {
                  // ----------------------------------------------------------------------------------------------------------------------------------
                  for ( d = 0; d < D; d++ ) {
                      // ----------------------------------------------------------------------------------------------------------------------------------
                      if // OK
                          continue;
                  }
              }
          }
      }
      
        • 1. Re: How to come back to the loop 1! …
          pixxxel schubser Level 5

          Hi Obi-wan Kenobi,

          deep nested loops are very time expensive. Try to avoid them.

          If necessary, put them in functions like this example (back to level before loop a-A)

           

          var a;
          function loopInNestedLoops () {
              var A = B = C = D = 3;
              for ( a = 0; a < A; a++ ) {
                  // ----------------------------------------------------------------------------------------------------------------------------------
                  for ( b = 0; b < B; b++ ) {
                      // ----------------------------------------------------------------------------------------------------------------------------------
                      for ( var c = 0; c < C; c++ ) {
                          // ----------------------------------------------------------------------------------------------------------------------------------
                          for ( d = 0; d < D; d++ ) {
                              // ----------------------------------------------------------------------------------------------------------------------------------
                              if (a === 1) {// OK  
                                  return a;
                              }
                          }
                      }
                  }
              }
          }
          
          loopInNestedLoops ();
          

           

          Have fun