POV-Ray : Newsgroups : povray.general : Nested #while statements Server Time
16 Nov 2024 03:23:12 EST (-0500)
  Nested #while statements (Message 1 to 3 of 3)  
From: Daniel Harris
Subject: Nested #while statements
Date: 5 Nov 1998 09:41:24
Message: <3641BA46.BB567AC6@netcom.co.uk>
Dear Pov'ers,
I was wondering if povray 3.02 can handle nested #while statements the
following code only outputs a single line of links in the z direction...

#declare X=0
#declare Y=0
#declare Z=0
#while (X<10)
       #while (Y<10)
              #while (Z<10)
                            object { link translate <X*1.75, Y*1.75,
Z*1.75> }
                            #declare Z=Z+1
              #end
              #declare Y=Y+1
       #end
       #declare X=X+1
#end

Please tell me if there is something blantantly wrong with this or if
povray doesn't do nested #while statements.

Dan.


Post a reply to this message

From: Ron Parker
Subject: Re: Nested #while statements
Date: 5 Nov 1998 10:46:35
Message: <3641c85b.0@news.povray.org>
On Thu, 05 Nov 1998 14:46:31 +0000, Daniel Harris 
	<d.h### [at] netcomcouk> wrote:
>#declare X=0
>#declare Y=0
>#declare Z=0
>#while (X<10)
***     #declare Y=0
>       #while (Y<10)
***            #declare Z=0
>              #while (Z<10)
>                            object { link translate <X*1.75, Y*1.75,
>Z*1.75> }
>                            #declare Z=Z+1
>              #end
>              #declare Y=Y+1
>       #end
>       #declare X=X+1
>#end
>
>Please tell me if there is something blantantly wrong with this or if
>povray doesn't do nested #while statements.

You need to set Y and Z to zero again each time through the outer loops.
(I've added the appropriate lines, marked with stars.)  The way you have 
it written, Z will be 10 after the first pass through the loop, so the 
inner loop will never execute again.  Result: a single line of links.


Post a reply to this message

From: Scott Hill
Subject: Re: Nested #while statements
Date: 5 Nov 1998 11:34:31
Message: <01be08da$6f716df0$8c00a8c0@shindo>
Daniel Harris <d.h### [at] netcomcouk> wrote in article
<3641BA46.BB567AC6@netcom.co.uk>...
> Dear Pov'ers,
> I was wondering if povray 3.02 can handle nested #while statements the
> following code only outputs a single line of links in the z direction...
> 
> #declare X=0
> #declare Y=0
> #declare Z=0
> #while (X<10)
>        #while (Y<10)
>               #while (Z<10)
>                             object { link translate <X*1.75, Y*1.75,
> Z*1.75> }
>                             #declare Z=Z+1
>               #end
>               #declare Y=Y+1
>        #end
>        #declare X=X+1
> #end
> 
> Please tell me if there is something blantantly wrong with this or if
> povray doesn't do nested #while statements.
> 

	You need to reset Y and Z each time round the X and Y loops, respectivly.
Something (well, exactly) like this:

#declare X=0
#while (X<10)
       #declare Y=0
       #while (Y<10)
              #declare Z=0
              #while (Z<10)
                            object { link translate <X*1.75, Y*1.75,
Z*1.75> }
                            #declare Z=Z+1
              #end
              #declare Y=Y+1
       #end
       #declare X=X+1
#end

HTH,
-- 
Scott Hill
Sco### [at] DDLinkscouk
Software Engineer (and all round nice guy)
Author of Pandora's Box
Company homepage : http://www.ddlinks.demon.co.uk

"The best trick the devil ever pulled was convincing people he didn't
exist..."
								- Verbal Kint.

"the Internet is here so we can waste time talking about nothing in 
 particular when we should be working" - Marcus Hill.


Post a reply to this message

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