You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Edgar S�nchez <ve...@yahoo.com> on 2001/08/23 17:03:46 UTC

Making Jumps or doing Loops!!

  Hi everyone is Vincent again...

    now I've 2 questions, well those are for the same
reason..
  I was wondering if here in Ant could I make some
jumps in order to repeat the same procedure with other
caracteristics, or if I can use loops like For or
While to do the same, keeping a counter in order to
make conditions to execute the same procedure or same
target with diferent actions.

  Is it possible?

  thank you
VES

=====

_________________________________________________________________

"Puedes sentirte desilusionado si fallas, pero est�s condenado si no lo intentas."

"You can get disappointed if you fail down, but you are doomed if you do not try it."

ICQ #  22338121


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: Making Jumps or doing Loops!!

Posted by Edgar S�nchez <ve...@yahoo.com>.
  Thanks Diane!! :-)

--- Diane Holt <ho...@yahoo.com> wrote:
> Actually, I'd take advantage of some of the new
> stuff available in 1.4
> (finally found some time to pick it up and start
> trying things out :) --
> namely, the new "inheritAll" attr for <antcall> and
> the new <condition>
> task, in conjunction with <propertyfile>'s
> incrementing functionality. For
> example:
> 
>   <property name="maxCount" value="10"/>
> 
>   <target name="doWhile">
>     <propertyfile file="counter.properties">
>       <entry key="counter" type="int"
> operation="+"/>
>     </propertyfile>
>     <property file="counter.properties"/>
>     <condition property="loopDone">
>       <equals arg1="${counter}" arg2="${maxCount}"/>
>     </condition>
>     <antcall target="doit"/>
>   </target>
> 
>   <target name="doit" unless="loopDone">
>     <echo message="Do stuff here..."/>
>     <antcall target="doWhile" inheritAll="no"/>
>   </target>
> 
> will "Do stuff here" 9 times (it's not zero-based :)
>  [Note: Make sure
> something removes counter.properties before the
> "doit" target gets run.]
> 
> Diane
> 
> --- Don Taylor <do...@yahoo.com> wrote:
> > 
> > --- Edgar S�nchez <ve...@yahoo.com> wrote:
> > >   Thanks Don
> > > 
> > >     just a question.
> > >    When you put the sample of the counter the
> "."
> > > after the counter means that the value will
> increment
> > > in one??
> > 
> > Not the value, the property name. I'm creating a
> series of properties:
> > 
> > counter
> > counter.
> > counter..
> > counter...
> > 
> > The value is whatever.
> > 
> > -- Don
> > 
> > >    <property name="${counter}." value="whatever"
> />
> > >   or how do I increment in one the variable
> value of
> > > my counter?
> > > 
> > >   Thanks again
> > > VES
> > > 
> > > 
> > > --- Don Taylor <do...@yahoo.com>
> wrote:
> > > > 
> > > > --- Edgar S�nchez <ve...@yahoo.com> wrote:
> > > > >   Hi everyone is Vincent again...
> > > > > 
> > > > >     now I've 2 questions, well those are for
> the
> > > > same
> > > > > reason..
> > > > >   I was wondering if here in Ant could I
> make some
> > > > > jumps in order to repeat the same procedure
> with
> > > > other
> > > > > caracteristics, 
> > > > 
> > > > Yes, check out the antcall task. This allows
> you to
> > > > execute the
> > > > same target multiple times with different sets
> of
> > > > "inputs".
> > > > 
> > > > 
> > > > or if I can use loops like For or
> > > > > While to do the same, keeping a counter in
> order
> > > > to
> > > > > make conditions to execute the same
> procedure or
> > > > same
> > > > > target with diferent actions.
> > > > > 
> > > > >   Is it possible?
> > > > 
> > > > When looping, you have to create a "kick-out"
> > > > condition. I used the
> > > > target's unless attribute. The idea is to loop
> until
> > > > the property is
> > > > set. However, because a target can't antcall
> itself,
> > > > you have to
> > > > replicate the target and have them cross-call
> each
> > > > other:
> > > > 
> > > > 
> > > > <target name="worker">
> > > >   <!-- This does the actual work. May depend
> on
> > > > other workers. -->
> > > > </target>
> > > > 
> > > > <target name="looper_1" depends="worker"
> > > > unless="some.condition">
> > > >   <antcall target="looper_2"/>
> > > > </target>
> > > > 
> > > > <target name="looper_2" depends="worker"
> > > > unless="some.condition">
> > > >   <antcall target="looper_1"/>
> > > > </target>
> > > > 
> > > > 
> > > > This takes care of while loops. I've never
> tried
> > > > implementing a for
> > > > loop in Ant. I suppose you could do something
> like
> > > > the following
> > > > in the worker target:
> > > > 
> > > > <property name="counter" value="counter" />
> > > > 
> > > > <target name="worker">
> > > >   <property name="${counter}."
> value="whatever" />
> > > > </target>
> > > > 
> > > > Then if you wanted to loop 3 times:
> > > > 
> > > > <target name="looper_1" depends="worker"
> > > > unless="counter...">
> > > >   <antcall target="looper_2"/>
> > > > </target>
> > > > 
> > > > <target name="looper_2" depends="worker"
> > > > unless="counter...">
> > > >   <antcall target="looper_1"/>
> > > > </target>
> > > > 
> > > > -- Don
> > > > 
> > > > 
> > > > > 
> > > > >   thank you
> > > > > VES
> > > > > 
> > > > > =====
> > > > > 
> > > > >
> > > >
> > >
>
_________________________________________________________________
> > > > > 
> > > > > "Puedes sentirte desilusionado si fallas,
> pero
> > > > est�s condenado si no
> > > > > lo intentas."
> > > > > 
> > > > > "You can get disappointed if you fail down,
> but
> > > > you are doomed if you
> > > > > do not try it."
> > > > > 
> > > > > ICQ #  22338121
> > > > > 
> > > > > 
> > > > >
> __________________________________________________
> > > > > Do You Yahoo!?
> > > > > Make international calls for as low as
> $.04/minute
> > > > with Yahoo!
> > > > > Messenger
> > > > > http://phonecard.yahoo.com/
> > > > 
> > > > 
> > > >
> __________________________________________________
> 
=== message truncated ===


=====

_________________________________________________________________

"Puedes sentirte desilusionado si fallas, pero est�s condenado si no lo intentas."

"You can get disappointed if you fail down, but you are doomed if you do not try it."

ICQ #  22338121


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

Re: Making Jumps or doing Loops!!

Posted by Diane Holt <ho...@yahoo.com>.
Actually, I'd take advantage of some of the new stuff available in 1.4
(finally found some time to pick it up and start trying things out :) --
namely, the new "inheritAll" attr for <antcall> and the new <condition>
task, in conjunction with <propertyfile>'s incrementing functionality. For
example:

  <property name="maxCount" value="10"/>

  <target name="doWhile">
    <propertyfile file="counter.properties">
      <entry key="counter" type="int" operation="+"/>
    </propertyfile>
    <property file="counter.properties"/>
    <condition property="loopDone">
      <equals arg1="${counter}" arg2="${maxCount}"/>
    </condition>
    <antcall target="doit"/>
  </target>

  <target name="doit" unless="loopDone">
    <echo message="Do stuff here..."/>
    <antcall target="doWhile" inheritAll="no"/>
  </target>

will "Do stuff here" 9 times (it's not zero-based :)  [Note: Make sure
something removes counter.properties before the "doit" target gets run.]

Diane

--- Don Taylor <do...@yahoo.com> wrote:
> 
> --- Edgar S�nchez <ve...@yahoo.com> wrote:
> >   Thanks Don
> > 
> >     just a question.
> >    When you put the sample of the counter the "."
> > after the counter means that the value will increment
> > in one??
> 
> Not the value, the property name. I'm creating a series of properties:
> 
> counter
> counter.
> counter..
> counter...
> 
> The value is whatever.
> 
> -- Don
> 
> >    <property name="${counter}." value="whatever" />
> >   or how do I increment in one the variable value of
> > my counter?
> > 
> >   Thanks again
> > VES
> > 
> > 
> > --- Don Taylor <do...@yahoo.com> wrote:
> > > 
> > > --- Edgar S�nchez <ve...@yahoo.com> wrote:
> > > >   Hi everyone is Vincent again...
> > > > 
> > > >     now I've 2 questions, well those are for the
> > > same
> > > > reason..
> > > >   I was wondering if here in Ant could I make some
> > > > jumps in order to repeat the same procedure with
> > > other
> > > > caracteristics, 
> > > 
> > > Yes, check out the antcall task. This allows you to
> > > execute the
> > > same target multiple times with different sets of
> > > "inputs".
> > > 
> > > 
> > > or if I can use loops like For or
> > > > While to do the same, keeping a counter in order
> > > to
> > > > make conditions to execute the same procedure or
> > > same
> > > > target with diferent actions.
> > > > 
> > > >   Is it possible?
> > > 
> > > When looping, you have to create a "kick-out"
> > > condition. I used the
> > > target's unless attribute. The idea is to loop until
> > > the property is
> > > set. However, because a target can't antcall itself,
> > > you have to
> > > replicate the target and have them cross-call each
> > > other:
> > > 
> > > 
> > > <target name="worker">
> > >   <!-- This does the actual work. May depend on
> > > other workers. -->
> > > </target>
> > > 
> > > <target name="looper_1" depends="worker"
> > > unless="some.condition">
> > >   <antcall target="looper_2"/>
> > > </target>
> > > 
> > > <target name="looper_2" depends="worker"
> > > unless="some.condition">
> > >   <antcall target="looper_1"/>
> > > </target>
> > > 
> > > 
> > > This takes care of while loops. I've never tried
> > > implementing a for
> > > loop in Ant. I suppose you could do something like
> > > the following
> > > in the worker target:
> > > 
> > > <property name="counter" value="counter" />
> > > 
> > > <target name="worker">
> > >   <property name="${counter}." value="whatever" />
> > > </target>
> > > 
> > > Then if you wanted to loop 3 times:
> > > 
> > > <target name="looper_1" depends="worker"
> > > unless="counter...">
> > >   <antcall target="looper_2"/>
> > > </target>
> > > 
> > > <target name="looper_2" depends="worker"
> > > unless="counter...">
> > >   <antcall target="looper_1"/>
> > > </target>
> > > 
> > > -- Don
> > > 
> > > 
> > > > 
> > > >   thank you
> > > > VES
> > > > 
> > > > =====
> > > > 
> > > >
> > >
> > _________________________________________________________________
> > > > 
> > > > "Puedes sentirte desilusionado si fallas, pero
> > > est�s condenado si no
> > > > lo intentas."
> > > > 
> > > > "You can get disappointed if you fail down, but
> > > you are doomed if you
> > > > do not try it."
> > > > 
> > > > ICQ #  22338121
> > > > 
> > > > 
> > > > __________________________________________________
> > > > Do You Yahoo!?
> > > > Make international calls for as low as $.04/minute
> > > with Yahoo!
> > > > Messenger
> > > > http://phonecard.yahoo.com/
> > > 
> > > 
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Make international calls for as low as $.04/minute
> > > with Yahoo! Messenger
> > > http://phonecard.yahoo.com/
> > 
> > 
> > =====
> > 
> > _________________________________________________________________
> > 
> > "Puedes sentirte desilusionado si fallas, pero est�s condenado si no
> > lo intentas."
> > 
> > "You can get disappointed if you fail down, but you are doomed if you
> > do not try it."
> > 
> > ICQ #  22338121
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute with Yahoo!
> > Messenger
> > http://phonecard.yahoo.com/
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: Making Jumps or doing Loops!!

Posted by Don Taylor <do...@yahoo.com>.
--- Edgar S�nchez <ve...@yahoo.com> wrote:
>   Thanks Don
> 
>     just a question.
>    When you put the sample of the counter the "."
> after the counter means that the value will increment
> in one??

Not the value, the property name. I'm creating a series of properties:

counter
counter.
counter..
counter...

The value is whatever.

-- Don

>    <property name="${counter}." value="whatever" />
>   or how do I increment in one the variable value of
> my counter?
> 
>   Thanks again
> VES
> 
> 
> --- Don Taylor <do...@yahoo.com> wrote:
> > 
> > --- Edgar S�nchez <ve...@yahoo.com> wrote:
> > >   Hi everyone is Vincent again...
> > > 
> > >     now I've 2 questions, well those are for the
> > same
> > > reason..
> > >   I was wondering if here in Ant could I make some
> > > jumps in order to repeat the same procedure with
> > other
> > > caracteristics, 
> > 
> > Yes, check out the antcall task. This allows you to
> > execute the
> > same target multiple times with different sets of
> > "inputs".
> > 
> > 
> > or if I can use loops like For or
> > > While to do the same, keeping a counter in order
> > to
> > > make conditions to execute the same procedure or
> > same
> > > target with diferent actions.
> > > 
> > >   Is it possible?
> > 
> > When looping, you have to create a "kick-out"
> > condition. I used the
> > target's unless attribute. The idea is to loop until
> > the property is
> > set. However, because a target can't antcall itself,
> > you have to
> > replicate the target and have them cross-call each
> > other:
> > 
> > 
> > <target name="worker">
> >   <!-- This does the actual work. May depend on
> > other workers. -->
> > </target>
> > 
> > <target name="looper_1" depends="worker"
> > unless="some.condition">
> >   <antcall target="looper_2"/>
> > </target>
> > 
> > <target name="looper_2" depends="worker"
> > unless="some.condition">
> >   <antcall target="looper_1"/>
> > </target>
> > 
> > 
> > This takes care of while loops. I've never tried
> > implementing a for
> > loop in Ant. I suppose you could do something like
> > the following
> > in the worker target:
> > 
> > <property name="counter" value="counter" />
> > 
> > <target name="worker">
> >   <property name="${counter}." value="whatever" />
> > </target>
> > 
> > Then if you wanted to loop 3 times:
> > 
> > <target name="looper_1" depends="worker"
> > unless="counter...">
> >   <antcall target="looper_2"/>
> > </target>
> > 
> > <target name="looper_2" depends="worker"
> > unless="counter...">
> >   <antcall target="looper_1"/>
> > </target>
> > 
> > -- Don
> > 
> > 
> > > 
> > >   thank you
> > > VES
> > > 
> > > =====
> > > 
> > >
> >
> _________________________________________________________________
> > > 
> > > "Puedes sentirte desilusionado si fallas, pero
> > est�s condenado si no
> > > lo intentas."
> > > 
> > > "You can get disappointed if you fail down, but
> > you are doomed if you
> > > do not try it."
> > > 
> > > ICQ #  22338121
> > > 
> > > 
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Make international calls for as low as $.04/minute
> > with Yahoo!
> > > Messenger
> > > http://phonecard.yahoo.com/
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute
> > with Yahoo! Messenger
> > http://phonecard.yahoo.com/
> 
> 
> =====
> 
> _________________________________________________________________
> 
> "Puedes sentirte desilusionado si fallas, pero est�s condenado si no
> lo intentas."
> 
> "You can get disappointed if you fail down, but you are doomed if you
> do not try it."
> 
> ICQ #  22338121
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo!
> Messenger
> http://phonecard.yahoo.com/


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: Making Jumps or doing Loops!!

Posted by Edgar S�nchez <ve...@yahoo.com>.
  Thanks Don

    just a question.
   When you put the sample of the counter the "."
after the counter means that the value will increment
in one??
   <property name="${counter}." value="whatever" />
  or how do I increment in one the variable value of
my counter?

  Thanks again
VES


--- Don Taylor <do...@yahoo.com> wrote:
> 
> --- Edgar S�nchez <ve...@yahoo.com> wrote:
> >   Hi everyone is Vincent again...
> > 
> >     now I've 2 questions, well those are for the
> same
> > reason..
> >   I was wondering if here in Ant could I make some
> > jumps in order to repeat the same procedure with
> other
> > caracteristics, 
> 
> Yes, check out the antcall task. This allows you to
> execute the
> same target multiple times with different sets of
> "inputs".
> 
> 
> or if I can use loops like For or
> > While to do the same, keeping a counter in order
> to
> > make conditions to execute the same procedure or
> same
> > target with diferent actions.
> > 
> >   Is it possible?
> 
> When looping, you have to create a "kick-out"
> condition. I used the
> target's unless attribute. The idea is to loop until
> the property is
> set. However, because a target can't antcall itself,
> you have to
> replicate the target and have them cross-call each
> other:
> 
> 
> <target name="worker">
>   <!-- This does the actual work. May depend on
> other workers. -->
> </target>
> 
> <target name="looper_1" depends="worker"
> unless="some.condition">
>   <antcall target="looper_2"/>
> </target>
> 
> <target name="looper_2" depends="worker"
> unless="some.condition">
>   <antcall target="looper_1"/>
> </target>
> 
> 
> This takes care of while loops. I've never tried
> implementing a for
> loop in Ant. I suppose you could do something like
> the following
> in the worker target:
> 
> <property name="counter" value="counter" />
> 
> <target name="worker">
>   <property name="${counter}." value="whatever" />
> </target>
> 
> Then if you wanted to loop 3 times:
> 
> <target name="looper_1" depends="worker"
> unless="counter...">
>   <antcall target="looper_2"/>
> </target>
> 
> <target name="looper_2" depends="worker"
> unless="counter...">
>   <antcall target="looper_1"/>
> </target>
> 
> -- Don
> 
> 
> > 
> >   thank you
> > VES
> > 
> > =====
> > 
> >
>
_________________________________________________________________
> > 
> > "Puedes sentirte desilusionado si fallas, pero
> est�s condenado si no
> > lo intentas."
> > 
> > "You can get disappointed if you fail down, but
> you are doomed if you
> > do not try it."
> > 
> > ICQ #  22338121
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute
> with Yahoo!
> > Messenger
> > http://phonecard.yahoo.com/
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute
> with Yahoo! Messenger
> http://phonecard.yahoo.com/


=====

_________________________________________________________________

"Puedes sentirte desilusionado si fallas, pero est�s condenado si no lo intentas."

"You can get disappointed if you fail down, but you are doomed if you do not try it."

ICQ #  22338121


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: Making Jumps or doing Loops!!

Posted by Don Taylor <do...@yahoo.com>.
--- Edgar S�nchez <ve...@yahoo.com> wrote:
>   Hi everyone is Vincent again...
> 
>     now I've 2 questions, well those are for the same
> reason..
>   I was wondering if here in Ant could I make some
> jumps in order to repeat the same procedure with other
> caracteristics, 

Yes, check out the antcall task. This allows you to execute the
same target multiple times with different sets of "inputs".


or if I can use loops like For or
> While to do the same, keeping a counter in order to
> make conditions to execute the same procedure or same
> target with diferent actions.
> 
>   Is it possible?

When looping, you have to create a "kick-out" condition. I used the
target's unless attribute. The idea is to loop until the property is
set. However, because a target can't antcall itself, you have to
replicate the target and have them cross-call each other:


<target name="worker">
  <!-- This does the actual work. May depend on other workers. -->
</target>

<target name="looper_1" depends="worker" unless="some.condition">
  <antcall target="looper_2"/>
</target>

<target name="looper_2" depends="worker" unless="some.condition">
  <antcall target="looper_1"/>
</target>


This takes care of while loops. I've never tried implementing a for
loop in Ant. I suppose you could do something like the following
in the worker target:

<property name="counter" value="counter" />

<target name="worker">
  <property name="${counter}." value="whatever" />
</target>

Then if you wanted to loop 3 times:

<target name="looper_1" depends="worker" unless="counter...">
  <antcall target="looper_2"/>
</target>

<target name="looper_2" depends="worker" unless="counter...">
  <antcall target="looper_1"/>
</target>

-- Don


> 
>   thank you
> VES
> 
> =====
> 
> _________________________________________________________________
> 
> "Puedes sentirte desilusionado si fallas, pero est�s condenado si no
> lo intentas."
> 
> "You can get disappointed if you fail down, but you are doomed if you
> do not try it."
> 
> ICQ #  22338121
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo!
> Messenger
> http://phonecard.yahoo.com/


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/