POV-Ray : Newsgroups : povray.bugreports : #while in a macro Server Time
28 Mar 2024 09:32:14 EDT (-0400)
  #while in a macro (Message 1 to 6 of 6)  
From: ruti
Subject: #while in a macro
Date: 16 Jan 2016 08:35:00
Message: <web.569a462899b4b92b7f8f5560@news.povray.org>
Hello
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:

Parse Error: No matching } in 'object', object found instead

I append the code which triggers the error:


//---------------------------------------------------------------------
#declare myBox = box {<0,0,0> <1,1,1> texture{pigment{color <1,1,1>}}}

#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)}
//---------------------------------------------------------------------

Maybe there's a solution from someone...

Greetings
Juerg


Post a reply to this message

From: ruti
Subject: Re: #while in a macro
Date: 16 Jan 2016 08:40:00
Message: <web.569a479a5b851d257f8f5560@news.povray.org>
"ruti" <jru### [at] ruti-agch> wrote:
> Hello
> 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:
>
> Parse Error: No matching } in 'object', object found instead
>
> I append the code which triggers the error:
>
>
> //---------------------------------------------------------------------
> #declare myBox = box {<0,0,0> <1,1,1> texture{pigment{color <1,1,1>}}}
>
> #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)}
> //---------------------------------------------------------------------
>
Using Windows 8 and POVRAY-Version 3.7 (64)
> Maybe there's a solution from someone...
>
> Greetings
> Juerg


Post a reply to this message

From: Le Forgeron
Subject: Re: #while in a macro
Date: 16 Jan 2016 08:48:15
Message: <569a4a1f$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Le 16/01/2016 14:32, ruti a écrit :
> #end
> 
> object { myMacro (0, 20, myBox)}

expanding by hand :

object { object { myBox ...


invalid construction.

Drop the 'object {' in front of myMacro and you will be fine.

Or replace it with an union.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iJwEAQEIAAYFAlaaSh4ACgkQhKAm8mTpkW3KcAQAsqbwOZRsRHytJujgviwh8XRa
s/jShkZx4keLrrsdDc6C0Um+nYaJGP927xsqtj4IiaHwZN2XqZo4xwT7DkIJ8WHy
eDXuahBnWFaMHRPGrGVY857RfjuS4AHiedMH7qBn/4LkMl41cbOWbsipGizKzeVd
3F/3VKSxmBI3Sjhinjw=
=mrgJ
-----END PGP SIGNATURE-----


Post a reply to this message

From: clipka
Subject: Re: #while in a macro
Date: 16 Jan 2016 14:11:44
Message: <569a95f0$1@news.povray.org>
Am 16.01.2016 um 14:48 schrieb Le_Forgeron:
> Le 16/01/2016 14:32, ruti a écrit :
>> #end
> 
>> object { myMacro (0, 20, myBox)}
> 
> expanding by hand :
> 
> object { object { myBox ...
> 
> 
> invalid construction.

No, that should be perfectly fine.


Post a reply to this message

From: clipka
Subject: Re: #while in a macro
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

From: ruti
Subject: Re: #while in a macro
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.