POV-Ray : Newsgroups : povray.bugreports : #while in a macro : Re: #while in a macro Server Time
17 Oct 2021 22:16:32 EDT (-0400)
  Re: #while in a macro  
From: clipka
Date: 16 Jan 2016 14:25:51
Message: <569a993f$1@news.povray.org>
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.


Post a reply to this message

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