POV-Ray : Newsgroups : povray.general : Nested loop problem (or maybe I'm just being stupid) Server Time
10 Aug 2024 03:24:39 EDT (-0400)
  Nested loop problem (or maybe I'm just being stupid) (Message 1 to 7 of 7)  
From: Richard Speir
Subject: Nested loop problem (or maybe I'm just being stupid)
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

From: Richard Speir
Subject: Re: Nested loop problem (or maybe I'm just being stupid)
Date: 23 Mar 2000 22:14:14
Message: <38DADE7C.CFB725A1@mindspring.com>
Bah!!  Cursed Netscape mail program!  Here's the code; hope it's clearer
now:

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

#while (a<layers+1)
    #while (b<sections+1)
        <insert macro here>
        #local b = b + 1;
    #end
#local a = a + 1;
#end


Post a reply to this message

From: Robert Chaffe
Subject: Re: Nested loop problem (or maybe I'm just being stupid)
Date: 23 Mar 2000 22:20:36
Message: <38dadf04@news.povray.org>
Note moved declaration of b below.  Is that what you need?
rc

"Richard Speir" <dai### [at] mindspringcom> wrote in message
news:38DADE7C.CFB725A1@mindspring.com...
> Bah!!  Cursed Netscape mail program!  Here's the code; hope it's clearer
> now:
>
> #declare a = 0;

/*  #declare b = 0;     <== removed this and moved down ...   */

> #declare layers = 3;
> #declare sections = 12;
>
> #while (a<layers+1)

      #declare b = 0;    /* ... to here.  */

>     #while (b<sections+1)
>         <insert macro here>
>         #local b = b + 1;
>     #end
> #local a = a + 1;
> #end


Post a reply to this message

From: Richard Speir
Subject: Re: Nested loop problem (or maybe I'm just being stupid)
Date: 23 Mar 2000 22:22:57
Message: <38DAE087.F34710FD@mindspring.com>
Yes! That's it!!  Man, I was being stupid.  Thanks a lot.


Post a reply to this message

From: Robert Chaffe
Subject: Re: Nested loop problem (or maybe I'm just being stupid)
Date: 23 Mar 2000 22:27:00
Message: <38dae084$1@news.povray.org>
Oh, and another thing, did you mean to use "#local" instead of
"#declare" within the loops?  Someone else might shed some
light on whether that mix is expected to work here.

rc

"Robert Chaffe" <a0003738@airmail.net> wrote in message
news:38dadf04@news.povray.org...
> Note moved declaration of b below.  Is that what you need?
> rc
>
> "Richard Speir" <dai### [at] mindspringcom> wrote in message
> news:38DADE7C.CFB725A1@mindspring.com...
> > Bah!!  Cursed Netscape mail program!  Here's the code; hope it's clearer
> > now:
> >
> > #declare a = 0;
>
> /*  #declare b = 0;     <== removed this and moved down ...   */
>
> > #declare layers = 3;
> > #declare sections = 12;
> >
> > #while (a<layers+1)
>
>       #declare b = 0;    /* ... to here.  */
>
> >     #while (b<sections+1)
> >         <insert macro here>
> >         #local b = b + 1;
> >     #end
> > #local a = a + 1;
> > #end


Post a reply to this message

From: Josh English
Subject: Re: Nested loop problem (or maybe I'm just being stupid)
Date: 27 Mar 2000 15:07:23
Message: <38DFBFAA.F870B48E@spiritone.com>
I do the same thing  every once in a while. It's embarrasing but at
least almost every single programmer has done it in the past, and some
of us post the code here so someone can point it out.

(I know this is true, because I've done it twice now)

Josh

Richard Speir wrote:

> Yes! That's it!!  Man, I was being stupid.  Thanks a lot.

--
Josh English
eng### [at] spiritonecom
"May your hopes, dreams, and plans not be destroyed by a few zeros."


Post a reply to this message

From: Peter Popov
Subject: Re: Nested loop problem (or maybe I'm just being stupid)
Date: 27 Mar 2000 17:40:27
Message: <zeLfOHf4ahhlfAOKYjp45311r37A@4ax.com>
On Mon, 27 Mar 2000 12:08:11 -0800, Josh English
<eng### [at] spiritonecom> wrote:

>I do the same thing  every once in a while. It's embarrasing but at
                                     ^^^^^^

That should read #while :)


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] usanet
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

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