ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From EXT / FOCAL MALAPRADE Roland <ext.focal.malapr...@sncf.fr>
Subject RE: If anybody is interested.. [foreach] task which doesnt run ou t of memory.
Date Wed, 18 Sep 2002 11:48:00 GMT
Hi Geoff,

I was wondering, can <foreach2> tasks be nested inside each other?

Roland.

-----Message d'origine-----
De : Matt Benson [mailto:gudnabrsam@yahoo.com]
Envoye : vendredi 13 septembre 2002 17:09
A : Ant Users List
Objet : RE: If anybody is interested.. [foreach] task which doesnt run
out of memory.


Yes, but the fact that the property is left set to the
last used value doesn't sit well with me.  It feels
like this would deprive you of something you have with
the "official" foreach:  the ability to use the param
name as a property later.  I guess this is just an
opinion question.  Other than that it seems like a
good idea though.

-Matt

--- Geoff Meakin <geoffm@isocra.com> wrote:
> > <foreach2 param="srcfile">
> >   <fileset dir="base">
> >     <include name="**/*.txt"/>
> >   </fileset>
> >   <do>
> >     <echo message="Found the following text file:
> > ${srcfile}"/>
> >   </do>
> > </foreach2>
> 
> In the example here, the value of the property
> ${srcfile} will be changed
> everytime the loop iterates. It isn't reset at the
> end of the loop (I
> thought about doing that) as the property might
> still be useful outside the
> foreach2 task, and there is no real reason to reset
> it, as that would give
> the property scope, and properties generally dont
> have scope in ANT. The ANT
> API still allows you to easily modify property
> values, even if this
> functionality has been taken away from <property>
> and <condition>, so it
> uses that mechanism to change the value of the
> property. Also- there really
> isnt a concept of "params" as such, as there was
> before (i.e. passing
> multiple properties to the called anttask)- because
> no target is being
> AntCalled.. The nested tasks have the same
> environment as the foreach task
> so they can access anything which is available.
> 
> As an alternative example, the code:
> <foreach2 param="letter" list="a,b,c,d,e">
>   <do><echo message="Letter ${letter}"/></do>
> </foreach2>
> 
> Will produce the following output:
> Letter a
> Letter b
> Letter c
> Letter d
> Letter e
> 
> And is in effect the same as doing:
> <property name="letter" value="a"><echo
> message="Letter ${letter}"/>
> <property name="letter" value="b"><echo
> message="Letter ${letter}"/>
> <property name="letter" value="c"><echo
> message="Letter ${letter}"/>
> <property name="letter" value="d"><echo
> message="Letter ${letter}"/>
> <property name="letter" value="e"><echo
> message="Letter ${letter}"/>
> 
> (if <property> allowed you to override the previous
> value that is (like in
> ANT1.4))
> 
> This is because each time the <echo> task is run,
> (one for each letter in
> the list), the value of the property
> ${letter} is equal to whichever letter in the list
> is being dealt with.
> 
> Does this help at all?
> Cheers
> -Geoff
> 
> >This sounds good, but how do you handle params? 
> Are
> >you changing properties to do this and then
> unsetting
> >them at the end of the loop, or what?
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:ant-user-help@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message