It happens. BTDT!
BOb
________________________________
From: Ken Rogoway [mailto:[EMAIL PROTECTED]
Sent: Tue 12/11/2007 6:11 PM
To: Bob Archer; nant-users@lists.sourceforge.net
Subject: RE: [NAnt-users] Using a property as a counter
I am an idiot. Please accept my humble apology.
I was restting the counter to 0 inside my foreach loop. DOH!
- K
-----Original Message-----
From: Bob Archer [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 11, 2007 4:42 PM
To: Ken Rogoway; nant-users@lists.sourceforge.net
Subject: RE: [NAnt-users] Using a property as a counter
Parameters overwrite by default. Here is a quick build file I tested this
with. Perhaps your if test isn't working. Throw an echo in it and see if it
displays as many times as you are expecting.
<project name="test">
<property name="Counter" value="0" />
<echo message="${Counter}" />
<property name="Counter" value="${int::parse(Counter)+int::parse(1)}"
/>
<echo message="${Counter}" />
<property name="Counter" value="${int::parse(Counter)+int::parse(1)}"
/>
<echo message="${Counter}" />
<property name="Counter" value="${int::parse(Counter)+int::parse(1)}"
/>
<echo message="${Counter}" />
</project>
-----Original Message-----
From: Ken Rogoway [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 11, 2007 5:10 PM
To: Bob Archer; nant-users@lists.sourceforge.net
Subject: RE: [NAnt-users] Using a property as a counter
I tried this and it still has the same behavior. WarningCounter gets bumped
to 1, but never increments after that.
Is there an overwrite param or something that is needed for the property?
- K
-----Original Message-----
From: Bob Archer [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 11, 2007 3:59 PM
To: Ken Rogoway; nant-users@lists.sourceforge.net
Subject: RE: [NAnt-users] Using a property as a counter
<property name="WarningCounter" value="0" />
<foreach item="Line" in="myfile.txt" property="oneLine">
<if test="${string::starts-with(oneLine,'WARNING')}">
<property name="WarningCounter"
value="${int::parse(WarningCounter)+int::parse(1)}" />
</if>
</foreach>
<echo>There were ${WarningCounter} warnings.</echo>
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ken Rogoway
Sent: Tuesday, December 11, 2007 4:27 PM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] Using a property as a counter
I want to count the number of times a particular <if> test is true.
I have the following Nant script snippet:
<property name="WarningCounter" value="0" />
<foreach item="Line" in="myfile.txt" property="oneLine">
<if test="${string::starts-with(oneLine,'WARNING')}">
<property name="WarningCounter"
value="${int::parse(WarningCounter)+1}" />
</if>
</foreach>
<echo>There were ${WarningCounter} warnings.</echo>
I always get 1 for the warning counter, even if there is more than one line
in the file with WARNING. I have also tried changing the int::parse()+1 to
convert::to-int()+1.
What is the proper way to do this?
Thanks,
- Ken Rogoway
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.17.1/1181 - Release Date:
12/11/2007
5:05 PM
------------------------------------------------------------------------
-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for just about anything Open
Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.17.1/1181 - Release Date:
12/11/2007
5:05 PM
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.17.1/1181 - Release Date:
12/11/2007
5:05 PM
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.17.1/1181 - Release Date: 12/11/2007
5:05 PM
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.17.1/1181 - Release Date: 12/11/2007
5:05 PM
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users