--- Saladin Sharif <[EMAIL PROTECTED]> wrote:
> >The 'count' and 'when' attributes are only relevant
> >(and the 'property' attribute is not) when you are
> >using <resourcecount> as a condition rather than as
> a
> >task. See
>
>http://ant.apache.org/manual/CoreTasks/condition.html
>
> I see. But the the link that you provided doesn't
> show how to use the <resourcecount> as a condition.
> If we do use <resourcecount> as a condition then
> does that mean it would execute whatever is enclosed
> within the <resourcecount> tag if the condition is
> true? I would think not. If you could provide an
> example of how to use <resourcecount> as a
> condition, then it would be very helpful in clearing
> up the confusion.
> Thanks,
> -Saladin
<condition property="file_has_lines_of_text"
value="true">
<resourcecount when="gt" count="0">
<tokens>
<file file="file_name.txt" />
</tokens>
</resourcecount>
</condition>
I admit I'm not sure how "file contains one or more
lines of text" differs from "file is not empty," so:
<condition property="file_is_not_empty" value="true">
<length file="file_name.txt" when="gt" length="0" />
</condition>
-Matt
>
>
>
>
**********************************************************
> * Saladin Sharif
> * e-mail: [EMAIL PROTECTED]
> * Visit homepage @ http://gaia.ecs.csus.edu/~sharifs
>
**********************************************************
>
>
> ----- Original Message ----
> From: Matt Benson <[EMAIL PROTECTED]>
> To: Ant Users List <[email protected]>; Saladin
> Sharif <[EMAIL PROTECTED]>
> Sent: Tuesday, October 9, 2007 12:48:34 PM
> Subject: Re: How to get the count of the number of
> lines in a file using ANT
>
>
> --- Saladin Sharif <[EMAIL PROTECTED]> wrote:
>
> > >Anyway, I didn't have time to put together the
> > example
> > >earlier. Here goes:
> > >
> > ><resourcecount>
> > > <tokens><!-- default tokenizer is a line
> > tokenizer
> > >-->
> > > <file file="file_name.txt" />
> > > </tokens>
> > ></resourcecount>
> >
> > Thanks Matt, I've tried the code that you have
> > given and it works. But what I am really after is
> > being able to set a flag if the file contains one
> or
> > more lines of text. So I was hoping to get the
> line
> > count and then check if it is greater than 0.
> > I took a look at the ANT user manual for the
> > resourcecount task, and noticed the "when" and
> > "count" attributes.
> >
> > <resourcecount
> > property="file.line.count.not.zero.flag"
> > when="greater" count="0" >
> > <tokens>
> > <file file="file_name.txt" />
> > </tokens>
> > </resourcecount>
> >
> > I tried using the above code snippet hoping that I
> > could set the file.line.count.not.zero.flag
> flag,
> > if the line count was greater than 0. But it does
> > not work the way I intended it. It just stores
> the
> > line count in the file.line.count.not.zero.flag
> > property regardless of wether the line count is
> > greater than 0 or not. I was hoping to be able to
> > set the flag, so that I could use it later on in
> my
> > ANT script as a condition to check before running
> > certain tasks.
> >
>
> The 'count' and 'when' attributes are only relevant
> (and the 'property' attribute is not) when you are
> using <resourcecount> as a condition rather than as
> a
> task. See
>
http://ant.apache.org/manual/CoreTasks/condition.html
>
> HTH,
> Matt
>
> >
> >
> >
> >
>
**********************************************************
> > * Saladin Sharif
> > * e-mail: [EMAIL PROTECTED]
> > * Visit homepage @
> http://gaia.ecs.csus.edu/~sharifs
> >
>
**********************************************************
> >
> >
> > ----- Original Message ----
> > From: Matt Benson <[EMAIL PROTECTED]>
> > To: Ant Users List <[email protected]>
> > Sent: Tuesday, October 9, 2007 8:16:50 AM
> > Subject: Re: How to get the count of the number of
> > lines in a file using ANT
> >
> >
> > --- Peter Reilly <[EMAIL PROTECTED]>
> > wrote:
> >
> > > On 10/9/07, Matt Benson <[EMAIL PROTECTED]>
> > > wrote:
> > > > Oh, ye of little faith... Look at:
> > > >
> > > >
> > >
> >
>
http://ant.apache.org/manual/CoreTypes/resources.html#tokens
> > > >
> > > > for a hint...
> > > It is *not* good to have such things in the
> > manual.
> >
> > How not, Peter?
> >
> > Anyway, I didn't have time to put together the
> > example
> > earlier. Here goes:
> >
> > <resourcecount>
> > <tokens><!-- default tokenizer is a line
> tokenizer
> > -->
> > <file file="file_name.txt" />
> > </tokens>
> > </resourcecount>
> >
> > -Matt
> >
> > >
> > > Peter
> > >
> > > >
> > > > -Matt
> > > >
> > > > --- Prashant Reddy <[EMAIL PROTECTED]>
> wrote:
> > > >
> > > > > Ok, none of the named filters that exist in
> > ANT
> > > dist
> > > > > can help achieve
> > > > > this. You might need to use the
> scriptfilter,
> > > and i
> > > > > am not an expert in
> > > > > using scripting lang.
> > > > >
> > > > > -Prashant
> > > > >
> > > > > On Tue, 2007-10-09 at 11:09 +0530, Prashant
> > > Reddy
> > > > > wrote:
> > > > > > checkout the filterchains:
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
http://ant.apache.org/manual/CoreTypes/filterchain.html
> > > > > >
> > > > > >
> > > > > > On Mon, 2007-10-08 at 15:20 -0700, Saladin
> > > Sharif
> > > > > wrote:
> > > > > > > I have a txt file and would like to get
> > the
> > > > > count of the number of lines in that file,
> and
> > > then
> > > > > store that count into a property.
> > > > > > >
> > > > > > > I mean something equivalent to the unix
> > > command:
> > > > > > > cat file_name.txt | wc -l
> > > > > > >
> > > > > > > Can this be done using an existing ANT
> > task?
> > > > > > > Thanks,
> > > > > > > -Saladin
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> > > >
> > >
> >
>
____________________________________________________________________________________
> > > > > > > Need a vacation? Get great deals
> > > > > > > to amazing places on Yahoo! Travel.
> > > > > > > http://travel.yahoo.com/
> > > > > > >
> > > > > > >
> > > > >
> > > >
> > >
> >
>
---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail:
> > > > > [EMAIL PROTECTED]
> > > > > > > For additional commands, e-mail:
> > > > > [EMAIL PROTECTED]
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
>
---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail:
> > > > > [EMAIL PROTECTED]
> > > > > For additional commands, e-mail:
> > > > > [EMAIL PROTECTED]
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
>
____________________________________________________________________________________
> > > > Don't let your dream ride pass you by. Make it
> a
> > > reality with Yahoo! Autos.
> > > > http://autos.yahoo.com/index.html
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
>
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
> > > [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > > [EMAIL PROTECTED]
> > >
> > >
> >
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Check out the hottest 2008 models today at Yahoo!
> > Autos.
> > http://autos.yahoo.com/new_cars.html
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Yahoo! oneSearch: Finally, mobile search
> > that gives answers, not web links.
> >
>
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> >
> >
>
>
>
>
>
____________________________________________________________________________________
> Check out the hottest 2008 models today at Yahoo!
> Autos.
> http://autos.yahoo.com/new_cars.html
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
>
>
____________________________________________________________________________________
> Boardwalk for $500? In 2007? Ha! Play Monopoly Here
> and Now (it's updated for today's economy) at Yahoo!
> Games.
>
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]