POV-Ray : Newsgroups : povray.general : Nested loop problem (or maybe I'm just being stupid) : Nested loop problem (or maybe I'm just being stupid) Server Time
10 Aug 2024 01:17:54 EDT (-0400)
  Nested loop problem (or maybe I'm just being stupid)  
From: Richard Speir
Date: 23 Mar 2000 22:06:07
Message: <38DADC93.885223B1@mindspring.com>
I've had problems with nested #while...#end loops in POV.  It will
execute the inner loop but not the outer.  My source is included, maybe
someone can hekp me with it.  Equivalent code in C++ using for loops
seems to work fine.  Are such constructs as I have simply illegal in POV
or am I just being stupid tonight?  I've tried rearranging the order of
the loops as well and either one will execute, or I will create a
neverending loop that sits and parses forever before I realize that one
of them never terminates.  Please help me!!

#declare a = 0;
#declare b = 0;
#declare layers = 3;
#declare sections = 12;

#while (a<layers+1)                                           // Outer
loop which only seems to execute the 1st iteration

   #while (b<sections+1)                      //
      <insert macro here>                      //  Inner loop which
seems
     #local b = b + 1;                            //   to execute
properly
   #end                                                //

#local a = a + 1;                                                //
Increment so the while statement will eventually be untrue
#end                                                                 //
End of outer loop #while statement


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.