ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geoff Meakin" <geo...@isocra.com>
Subject RE: If anybody is interested.. [foreach] task which doesnt run ou t of memory.
Date Thu, 19 Sep 2002 14:17:31 GMT
This is a problem with the way nested text in an echo is added
each time the task is run. I'll take a look at this now.
In the meantime, if you use <echo message=""/> format instead
it should work.

Thanks again
Cheers
-Geoff

-----Original Message-----
From: EXT / FOCAL MALAPRADE Roland [mailto:ext.focal.malaprade@sncf.fr]
Sent: 19 September 2002 10:04 AM
To: 'Ant Users List'
Subject: RE: If anybody is interested.. [foreach] task which doesnt run
ou t of memory.


Hi Geoff,

I gave it a bash, the problem is that the example I gave you is a cut down
version of my build script (obviously), and it wasn't really representative
of it.

Here's another example:

<target name="main">
  <foreach2 param="iteration" list="1,2">
    <do>
	<!-- PROBLEM HERE WITH THE ECHO -->
      <echo>Iteration ${iteration} :</echo>
      <echo/>
      <foreach2 param="letter" list="a,b">
        <do>
          <if>
            <isset property="letter"/>
            <then>
              <foreach2 param="number" list="1,2">
                <do>
                  <if>
                  <isset property="letter"/>
                  <then>
                    <echo message="combi is ${iteration}.
${letter}-${number}"/>
                  </then>
                  <else>
                    <echo message="number not set" />
                  </else>
                  </if>
                </do>
              </foreach2>
            </then>
            <else>
              <echo message="letter not set" />
            </else>
          </if>
        </do>
      </foreach2>
    </do>
  </foreach2>
</target>

And this gives the following output:

Iteration 1 :

combi is 1. a-1
combi is 1. a-2
combi is 1. b-1
combi is 1. b-2
Iteration 1 :Iteration 2 :

combi is 2. a-1
combi is 2. a-2
combi is 2. b-1
combi is 2. b-2


In the <do> of the first <foreach2> I've added an echo which seems to get
called as many times per iteration as the "number" of the iteration. If I
add another echo to the second <do> task, every task seems to get called
called in a totally weird order.

Is there any obvious fix for this?

Anyway thanks a stack for the time you've devoted to this, and even if you
don't have the time to fix this, I've really appreciated your help.

Cheers, Roland.

-----Message d'origine-----
De : EXT / FOCAL MALAPRADE Roland [mailto:ext.focal.malaprade@sncf.fr]
Envoyé : jeudi 19 septembre 2002 09:50
À : 'Ant Users List'
Objet : RE: If anybody is interested.. [foreach] task which doesnt run
ou t of memory.


Wow! Cool! thanks a lot. I'll try it out.

Roland.

-----Message d'origine-----
De : Geoff Meakin [mailto:geoffm@isocra.com]
Envoyé : mercredi 18 septembre 2002 18:40
À : Ant Users List
Objet : RE: If anybody is interested.. [foreach] task which doesnt run
out of memory.


Dear Roland,

Yes, the difficulty comes in with the fact that
IfTask isnt really an org.apache.tools.ant.Task
but is a ConditionBase instead, with private
<then> and <else> Sequentials, so I cant access
them, and notify them that they need to reset
their properties.

I've changed this by modifying execute() on
Sequential so that it resets its properties from
there instead, so your example now works (as does
mine). This now happens with all <Sequentials>,
but I cant see how that should have any adverse
effects.

If you're happy with this, you can get
the new version (ForEach2 v0.8.1) from the same
place.

Thanks for pointing this out :)

Cheers
-Geoff


-----Original Message-----
From: EXT / FOCAL MALAPRADE Roland [mailto:ext.focal.malaprade@sncf.fr]
Sent: 18 September 2002 02:42 PM
To: 'Ant Users List'
Subject: RE: If anybody is interested.. [foreach] task which doesnt run
out of memory.


I've been trying to use it with an <if> task as so:

<target name="main">
  <foreach2 param="letter" list="a,b,c">
    <do>
      <if>
        <isset property="letter"/>
        <then>
          <foreach2 param="number" list="1,2,3">
            <do>
              <if>
                <isset property="letter"/>
                <then>
                  <echo message="combi is ${letter}${number}"/>
                </then>
                <else>
                  <echo message="number not set" />
                </else>
              </if>
            </do>
          </foreach2>
        </then>
        <else>
          <echo message="letter not set" />
        </else>
      </if>
    </do>
  </foreach2>

and this build script displays:
main:
     [echo] combi is a1
     [echo] combi is a1
     [echo] combi is a1
     [echo] combi is a1
     [echo] combi is a1
     [echo] combi is a1
     [echo] combi is a1
     [echo] combi is a1
     [echo] combi is a1

Do you know why this is?

</target>-----Message d'origine-----
De : Geoff Meakin [mailto:geoffm@isocra.com]
Envoyé : mercredi 18 septembre 2002 15:09
À : Ant Users List
Objet : RE: If anybody is interested.. [foreach] task which doesnt run
out of memory.


Yes, it appears so:

<target name="main">
  <foreach2 param="letter" list="a,b,c">
    <do>
      <foreach2 param="number" list="1,2,3">
        <do>
          <echo message="combi is ${letter}${number}"/>
        </do>
      </foreach2>
    </do>
  </foreach2>
</target>

Gives the output:

combi is a1
combi is a2
combi is a3
combi is b1
combi is b2
combi is b3
combi is c1
combi is c2
combi is c3

Cheers
-Geoff


--
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>



--
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>

--
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