You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Guru Balse <gu...@oracle.com> on 2006/06/09 22:01:57 UTC
Re: For loop
Awesome, Scot. It works well! Can't wait for the "better" solution
that you are about to create :-)
You must use 1.6.5 for this (for example, 1.6.2 did not work)
<project name="looper" default="test">
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpath="/apache-ant-1.6.5ant1.6.2/lib/ant-contrib-1.0b1.jar" />
<macrodef name = "jp-for">
<attribute name = "param" description = "The name of the param
containing the current value of the loop"/>
<attribute name = "lower" default = "1" description = "The
lower bounds of the loop"/>
<attribute name = "upper" description = "The upper bounds of the
loop"/>
<attribute name = "step" default = "1" description = "The
upper bounds of the loop"/>
<element name = "loop" implicit = "true" description = "The
enclosing block - just like ant contrib's for/sequential"/>
<sequential>
<var name = "@{param}" value = "@{lower}"/>
<if><not><equals arg1 = "${@{param}}" arg2 = "@{upper}"/></not>
<then>
<loop/>
<math result = "@{param}" datatype = "int"
operation = "+" operand1 = "${@{param}}" operand2 = "@{step}"/>
<jp-for param = "@{param}" lower = "${@{param}}"
upper = "@{upper}" step = "@{step}">
<loop/>
</jp-for>
</then>
</if>
</sequential>
</macrodef>
<target name="test">
<jp-for param="outer" lower="0" upper="5">
<jp-for param="inner" lower="0" upper="6">
<echo> parameters are now: (${outer},${inner})</echo>
</jp-for>
</jp-for>
</target>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: For loop
Posted by "Scot P. Floess" <fl...@mindspring.com>.
Yes, I am using 1.6.5. I never tested using an inner for loop - did it
work?
Guru Balse wrote:
> Awesome, Scot. It works well! Can't wait for the "better" solution
> that you are about to create :-)
> You must use 1.6.5 for this (for example, 1.6.2 did not work)
>
> <project name="looper" default="test">
> <taskdef resource="net/sf/antcontrib/antcontrib.properties"
> classpath="/apache-ant-1.6.5ant1.6.2/lib/ant-contrib-1.0b1.jar" />
> <macrodef name = "jp-for">
> <attribute name = "param" description = "The name of the param
> containing the current value of the loop"/>
> <attribute name = "lower" default = "1" description = "The
> lower bounds of the loop"/>
> <attribute name = "upper" description = "The upper bounds of
> the loop"/>
> <attribute name = "step" default = "1" description = "The
> upper bounds of the loop"/>
> <element name = "loop" implicit = "true" description = "The
> enclosing block - just like ant contrib's for/sequential"/>
> <sequential>
> <var name = "@{param}" value = "@{lower}"/>
> <if><not><equals arg1 = "${@{param}}" arg2 =
> "@{upper}"/></not>
> <then>
> <loop/>
> <math result = "@{param}" datatype = "int"
> operation = "+" operand1 = "${@{param}}" operand2 = "@{step}"/>
> <jp-for param = "@{param}" lower = "${@{param}}"
> upper = "@{upper}" step = "@{step}">
> <loop/>
> </jp-for>
> </then>
> </if>
> </sequential>
> </macrodef>
>
> <target name="test">
> <jp-for param="outer" lower="0" upper="5">
> <jp-for param="inner" lower="0" upper="6">
> <echo> parameters are now: (${outer},${inner})</echo>
> </jp-for>
> </jp-for>
> </target>
> </project>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-754-4592 (Work)
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org