|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
for statement possibilitiesHi all,
I am using the 'for-statement' from Ant-Contrib. I have two questions about it: 1. Is it possible to stop within the for statement while it isn't ended yet? 2. Is it possible to use integers within a for statement? For example: <!-- starts for statement with number = 0, increasing 1 after each iteration --> <for> <if><equals arg1="${number}" arg2="3" /><then> <!-- stop --> </then><else> <!-- continue --> </else></if> </for> I hope again someone can help me. Thanks! EetieD. |
|
|
Re: for statement possibilitiesOn Tue, Oct 13, 2009 at 12:11, EetieD <khn@...> wrote:
> > Hi all, > > I am using the 'for-statement' from Ant-Contrib. I have two questions about > it: > > 1. Is it possible to stop within the for statement while it isn't ended yet? Yes it is, with a "catch" - quite literally so: <trycatch> <try> <for> <!-- whatever ---> <!-- when condition is met to exit loop, do: --> <fail/> </for> </try> <catch> <!-- End of loop - catch statement possibly empty --> </catch> </trycatch> > 2. Is it possible to use integers within a for statement? > > For example: > > <!-- starts for statement with number = 0, increasing 1 after each iteration > --> > <for> > <if><equals arg1="${number}" arg2="3" /><then> > <!-- stop --> > </then><else> > <!-- continue --> > </else></if> > </for> > Yessir. Use ant-contrib's <math> statement, with ant-contrib's <var>. And use ant's <macrodef> for even more convenience. Demonstration: ---- build@build ~ $ cat t.xml <project name="t" default="doit" basedir="."> <taskdef resource="net/sf/antcontrib/antlib.xml"/> <macrodef name="inc"> <attribute name="victim"/> <sequential> <math result="@{victim}" operand1="${@{victim}}" operation="+" operand2="1" datatype="int"/> </sequential> </macrodef> <var name="t" value="1"/> <target name="doit"> <inc victim="t"/> <echo message="${t}"/> </target> </project> build@build ~ $ ant -f t.xml Buildfile: t.xml doit: [echo] 2 ---- You have to wonder why ant-contrib isn't integrated within ant yet... Plain ant just cannot do this without <script>. -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: for statement possibilitiesThanks, very useful!
|
| Free embeddable forum powered by Nabble | Forum Help |