POV-Ray : Newsgroups : povray.general : Some Basic Loop Questions Server Time
3 Aug 2024 02:20:45 EDT (-0400)
  Some Basic Loop Questions (Message 1 to 8 of 8)  
From: Glen Berry
Subject: Some Basic Loop Questions
Date: 22 Jun 2004 18:45:51
Message: <gbnhd09fb5vqngh5328bhku6cg41lner6u@4ax.com>
I'd like to know if the following things are possible within POV-Ray's
scene language, either directly or via some indirect workaround.

1)  When doing a while loop, is it possible to conditionally abort the
loop and continue processing the rest of the scene file, if a certain
condition tests true? I believe this ability exists in some
programming languages, but I don't know how to do it with POV.


2)  Is it possible to combine tests within an #if statement? Imagine
something roughly like this:

#if (A>2) AND (B>3)
   DoStuffHere
#end


I'd like to know how to accomplish the equivalent of these ideas. I'm
not expecting POV to support them directly. Any help is appreciated.


thanks,
Glen


Post a reply to this message

From: Apache
Subject: Re: Some Basic Loop Questions
Date: 22 Jun 2004 19:27:33
Message: <40d8c065@news.povray.org>
something like the following:

#if ((A > 2) & (B > 3))
    DoStuffHere
#end


another example:

#local I = 0;
#while (I < 10)
    RepeatThisTenTimes
    #declare I = I + 1;
#end


Post a reply to this message

From: Alain
Subject: Re: Some Basic Loop Questions
Date: 22 Jun 2004 20:20:12
Message: <40d8ccbc$1@news.povray.org>
Glen Berry nous apporta ses lumieres ainsi en ce 22/06/2004 21:45... :

>I'd like to know if the following things are possible within POV-Ray's
>scene language, either directly or via some indirect workaround.
>
>1)  When doing a while loop, is it possible to conditionally abort the
>loop and continue processing the rest of the scene file, if a certain
>condition tests true? I believe this ability exists in some
>programming languages, but I don't know how to do it with POV.
>  
>
Yes like this:
#local I=0;
#while(I<10)
    <<some code>>
    #if(stopingcondition)#local SaveIndex=I; // only if you need to 
preserve the index at whitch the stop condition became true.
        #local I=10;#end // Set the loop index past the end value!
    #local I = I + 1;
#end

Alain


Post a reply to this message

From: Mike Raiford
Subject: Re: Some Basic Loop Questions
Date: 23 Jun 2004 08:08:42
Message: <40d972ca$1@news.povray.org>
Alain wrote:
> Glen Berry nous apporta ses lumieres ainsi en ce 22/06/2004 21:45... :
> 
>> I'd like to know if the following things are possible within POV-Ray's
>> scene language, either directly or via some indirect workaround.
>>
>> 1)  When doing a while loop, is it possible to conditionally abort the
>> loop and continue processing the rest of the scene file, if a certain
>> condition tests true? I believe this ability exists in some
>> programming languages, but I don't know how to do it with POV.
>>  
>>
> Yes like this:
> #local I=0;
> #while(I<10)
>    <<some code>>
>    #if(stopingcondition)#local SaveIndex=I; // only if you need to 
> preserve the index at whitch the stop condition became true.
>        #local I=10;#end // Set the loop index past the end value!
>    #local I = I + 1;
> #end
> 
> Alain

What amazes me about this is one simple question has resulted in three 
different answers... ;)

If the POV-Team is following this: Might I suggest a #break and a 
#continue statement? :)


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Some Basic Loop Questions
Date: 23 Jun 2004 13:25:20
Message: <40d9bd00$1@news.povray.org>
In article <40d972ca$1@news.povray.org> , Mike Raiford 
<mra### [at] hotmailcom>  wrote:

> If the POV-Team is following this: Might I suggest a #break and a
> #continue statement? :)

It is extremely bad programming practice to have an multiple execution paths
to leave a loop.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Mike Raiford
Subject: Re: Some Basic Loop Questions
Date: 23 Jun 2004 13:43:51
Message: <40d9c157@news.povray.org>
Thorsten Froehlich wrote:

> In article <40d972ca$1@news.povray.org> , Mike Raiford 
> <mra### [at] hotmailcom>  wrote:
> 
> 
>>If the POV-Team is following this: Might I suggest a #break and a
>>#continue statement? :)
> 
> 
> It is extremely bad programming practice to have an multiple execution paths
> to leave a loop.
> 
>     Thorsten
> 

Hm. You have a point there. Ideally the condition of the loop should 
determine when to leave the loop. But .... But.. err. hmm, I have no 
excuse for wanting such a feature :)

Come to think of it, The only time I have ever used break in C is in the 
switch statement... (Next, I'm sure I'll hear how switch statements are 
poor programming practice in most situations... except when writing 
Windows Message handlers ...)


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Some Basic Loop Questions
Date: 24 Jun 2004 03:28:50
Message: <40da82b2@news.povray.org>
In article <40d9c157@news.povray.org> , Mike Raiford <mra### [at] hotmailcom>
wrote:

> Come to think of it, The only time I have ever used break in C is in the
> switch statement... (Next, I'm sure I'll hear how switch statements are
> poor programming practice in most situations... except when writing
> Windows Message handlers ...)

No, switch statements are an extremely important control structure good for
much more than you think.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Glen
Subject: Re: Some Basic Loop Questions
Date: 26 Jun 2004 01:12:44
Message: <uibqd05c2hjivpl0gmf0tl8bm5lgl8me81@4ax.com>
On Wed, 23 Jun 2004 19:25:19 +0200, "Thorsten Froehlich"
<tho### [at] trfde> wrote:


>It is extremely bad programming practice to have an multiple execution paths
>to leave a loop.
>
>    Thorsten

Yes, I thought I had read that somewhere. Once I was shown the proper
syntax for simultaneously testing two conditions using the  '&'
symbol, I didn't need the multiple exit paths. 

I hope this isn't also considered poor programming.   ;)

Thanks everyone, for all the suggestions. It was the '&' symbol
suggestion that solved my problem.

later,
Glen


Post a reply to this message

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