POV-Ray : Newsgroups : povray.general : question on the if loop Server Time
29 Jul 2024 16:25:40 EDT (-0400)
  question on the if loop (Message 1 to 4 of 4)  
From: Brandeis University
Subject: question on the if loop
Date: 15 Apr 2011 14:05:01
Message: <web.4da8879abf3208095273643f0@news.povray.org>
Hi,
I'm making a while loop that goes from n=1 to 100.
for each n I'm drawing an object
However for n=2, 8 and 10 I would like not to draw this object how to I do?
I can do an If loop:
If n=2 then don't draw else draw end. Problem: that just deals with n=2.
but I don't know how to do if n=2 or 8 or 9, ... else ... end
Could someone please help me?
Thank you, Thomas


Post a reply to this message

From: Alain
Subject: Re: question on the if loop
Date: 15 Apr 2011 14:19:55
Message: <4da88c4b@news.povray.org>

> Hi,
> I'm making a while loop that goes from n=1 to 100.
> for each n I'm drawing an object
> However for n=2, 8 and 10 I would like not to draw this object how to I do?
> I can do an If loop:
> If n=2 then don't draw else draw end. Problem: that just deals with n=2.
> but I don't know how to do if n=2 or 8 or 9, ... else ... end
> Could someone please help me?
> Thank you, Thomas
>
>
>

#if(N=2 | N=8 | N=10 | ...)
// do nothing
#else
// draw your stuff
#end

You can reverse the test:
#if(N!=2 & N!=8 & N!=10 &...)
// draw your stuff
#end


The pipe "|" is the OR operator (true if at least one condition is true).
The ampersand "&" is the AND operator (true if all conditions are true).




Alain


Post a reply to this message

From: Le Forgeron
Subject: Re: question on the if loop
Date: 15 Apr 2011 14:20:09
Message: <4da88c59$1@news.povray.org>
Le 15/04/2011 20:01, Brandeis University nous fit lire :
> Hi,
> I'm making a while loop that goes from n=1 to 100.
> for each n I'm drawing an object
> However for n=2, 8 and 10 I would like not to draw this object how to I do?
> I can do an If loop:
> If n=2 then don't draw else draw end. Problem: that just deals with n=2.
> but I don't know how to do if n=2 or 8 or 9, ... else ... end
> Could someone please help me?

Have a look at #switch / #case / #range / #break / #else / #end


Post a reply to this message

From: Brandeis University
Subject: Re: question on the if loop
Date: 15 Apr 2011 15:05:00
Message: <web.4da89610da238dc55273643f0@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:

> > Hi,
> > I'm making a while loop that goes from n=1 to 100.
> > for each n I'm drawing an object
> > However for n=2, 8 and 10 I would like not to draw this object how to I do?
> > I can do an If loop:
> > If n=2 then don't draw else draw end. Problem: that just deals with n=2.
> > but I don't know how to do if n=2 or 8 or 9, ... else ... end
> > Could someone please help me?
> > Thank you, Thomas
> >
> >
> >
>
> #if(N=2 | N=8 | N=10 | ...)
> // do nothing
> #else
> // draw your stuff
> #end
>
> You can reverse the test:
> #if(N!=2 & N!=8 & N!=10 &...)
> // draw your stuff
> #end
>
>
> The pipe "|" is the OR operator (true if at least one condition is true).
> The ampersand "&" is the AND operator (true if all conditions are true).
>
>
>
> Alain

Perfect, thank you Alain. Thomas


Post a reply to this message

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