POV-Ray : Newsgroups : povray.general : while () { while () {}} doesn't work propertly. : Re: while () { while () {}} doesn't work propertly. Server Time
7 Aug 2024 13:15:01 EDT (-0400)
  Re: while () { while () {}} doesn't work propertly.  
From: Trevor Quayle
Date: 25 Sep 2001 16:28:15
Message: <3bb0e8df@news.povray.org>
You need to redeclare cGreen as 0 again at the end of the cGreen loop to
reset it back to 0

-tgq


"Eitan Tal" <eit### [at] netvisionnetil> wrote in message
news:3BB0E68B.B75F68DB@netvision.net.il...
> It looks like it ignores the first while.
> Take a look at this:
> #declare cRed=0
> #declare cGreen=0
>
> #while (cRed < 1)
>     #while (cGreen < 1)
>         sphere {<cRed*2.5,cGreen*2.5, 0>, 0.2 pigment {color rgb <cRed,
> cGreen, 0>}}
>         #declare cGreen=cGreen+0.1
>     #end

        #declare cGreen=0  // add this

>     #declare cRed=cRed+0.1
> #end
>
> It only makes 10 objects (this is what written in Messages)
> and cRed always = 0. it looks like it only supports one #while.
>
> possible (and easy) to do a workaround using mod (modulo, % in c++)
> possible (but annoying) to do with a switch. do I have to use the
> switch? or maybe it was fixed in a newer version? I'm running here
> #version 3.1
>
> BTW: I don't like the ; semicolon after #declare. it seems so wrong for
> me, because it is a #directive that goes to the compiler. on C++, it
> will Not have ; semicolon.
>


Post a reply to this message

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