POV-Ray : Newsgroups : povray.bugreports : #while in a macro : Re: #while in a macro Server Time
9 Nov 2024 06:10:19 EST (-0500)
  Re: #while in a macro  
From: ruti
Date: 17 Jan 2016 04:55:00
Message: <web.569b63dc5b851d257f8f5560@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 16.01.2016 um 14:32 schrieb ruti:
>
> > I just discovered something, which Looks to me like a bug: When I try to use
> > #while in a macro, I get an error-message:
>
> Ho-hum! Let's not be hasty. What happened to the good old-fashioned "am
> I doing something wrong myself?" phase of troubleshooting? Gone out of
> style?
>
> > Parse Error: No matching } in 'object', object found instead
>
> No surprise there, because this code...
>
> > #macro myMacro (myStart, myEnd, myBox)
> >    #local myVar = myStart;
> >
> >    #while (myVar <10)
> >        object {myBox translate <myVar,0,0>}    //Here occurs the error
> >       #local myVar = myVar + 2;
> >    #end
> > #end
> >
> > object { myMacro (0, 20, myBox)}
>
> ... essentially expands to:
>
>   object {
>     // your macro begins here
>       // a single iteration of your loop begins here
>       object { ... }
>       // a single iteration of your loop ends here
>       // a single iteration of your loop begins here
>       object { ... }
>       // a single iteration of your loop ends here
>       // a single iteration of your loop begins here
>       object { ... }
>       // a single iteration of your loop ends here
>       ...
>     // your macro ends here
>   }
>
> You can't bundle multiple objects in a single "object {...}" statement,
> because... well, it's simply not what it is supposed to do. That would
> be the "union" statement instead.
>
> Either change the macro invocation to:
>
>   union { myMacro (0, 20, myBox)}
>
> or change the macro to:
>
>   #macro myMacro (myStart, myEnd, myBox)
>     union {
>       #local myVar = myStart;
>
>       #while (myVar <10)
>         ...
>       #end
>     }
>   #end
>
>
> Not a bug. Case closed. If you have any more inquiries, please move on
> to povray.general, povray.newusers or povray.advanced, depending on the
> level of expertise you presume to have.

Sorry for that...
These two statements I tried and they work:

myMacro (0, 20, myBox)
union {myMacro (0,20,myBox)}

Thanks


Post a reply to this message

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