POV-Ray : Newsgroups : povray.general : while-loop in macro : Re: while-loop in macro Server Time
5 Nov 2024 18:24:12 EST (-0500)
  Re: while-loop in macro  
From: Christopher James Huff
Date: 23 Feb 2003 17:33:07
Message: <cjameshuff-A5EFF5.17294623022003@netplex.aussie.org>
In article <web.3e594598d27a3e2ede2a6cfb0@news.povray.org>,
 "Lenx" <lenx_@hotmail.com> wrote:

> Jellby wrote:
> >
> >So you finally have:
> >
> >object {
> >  cylinder { }
> >  translate
> >  cylinder { }
> >  translate
> >  ...
> >}
> 
> i don't understand how you come to that :-s

Your macro:
#macro Fence(Flength, Fheight, Fspace, Fdiam)
   #local i=0;
   #while(i< Flength/Fspace+1 )
      cylinder{ <0,0,0> <0,Fheight,0> Fdiam/2 }
      translate <i*Fspace, 0, 0>
     #local i=i+1;
   #end
#end

It loops over a cylinder and translate statement. You then call it in an 
object block...and get the expected result.
Since your translate statement is apparently intended to translate the 
cylinder, it should go in the cylinder block. And an object block can 
only contain one object, you need to put either the macro call or the 
loop itself in a union.

BTW, your "i" variable is poorly named. It is a good idea to always use 
at least one upper-case letter in a variable name, which will prevent 
conflicts with future keywords.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

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