comp.lang.ada
 help / color / mirror / Atom feed
* sequential search
@ 2003-03-09 18:08 David
  0 siblings, 0 replies; 4+ messages in thread
From: David @ 2003-03-09 18:08 UTC (permalink / raw)


Does anyone know how a sequential/linear search is created under a txt
file (to find a specific word line by line).  I have an idea how it is
done using an array, but not under a file.  Any ideas?

Thanks.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: sequential search
@ 2003-03-10 13:09 Beard, Frank Randolph CIV
  2003-03-10 17:27 ` Martin Krischik
  0 siblings, 1 reply; 4+ messages in thread
From: Beard, Frank Randolph CIV @ 2003-03-10 13:09 UTC (permalink / raw)
  To: comp.lang.ada mail to news gateway

There's good 'ol fashioned Ada.Text_Io.Get_Line.  Create a buffer
of sufficient size.  Call Get_Line to read the file line by line, and
then parse the buffer looking for the particular word (maintaining a
line counter as you go).

If your application is interactive where the user will make multiple
queries, you might be better off reading the entire file into a memory
buffer and then parsing it.  If speed and efficiency are not paramount,
then the first approach will probably suffice.

Frank

-----Original Message-----
From: David

Does anyone know how a sequential/linear search is created under a txt
file (to find a specific word line by line).  I have an idea how it is
done using an array, but not under a file.  Any ideas?

Thanks.
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sequential search
       [not found] <87C00083D21D6944A12CB3F8C22DBEEE18821B@NAEAWNYDEX08VA.nadsusea.nads.navy.mil>
@ 2003-03-10 14:13 ` David C. Hoos
  0 siblings, 0 replies; 4+ messages in thread
From: David C. Hoos @ 2003-03-10 14:13 UTC (permalink / raw)
  To: comp.lang.ada mail to news gateway

The Line counter is maintained for you by Ada.Text_IO -- the number of
the line jus read is given by Ada.Text_IO.Line (File) - 1


----- Original Message ----- 
From: "Beard, Frank Randolph CIV" <frank.beard@navy.mil>
To: "comp.lang.ada mail to news gateway" <comp.lang.ada@ada.eu.org>
Sent: Monday, March 10, 2003 7:09 AM
Subject: RE: sequential search


There's good 'ol fashioned Ada.Text_Io.Get_Line.  Create a buffer
of sufficient size.  Call Get_Line to read the file line by line, and
then parse the buffer looking for the particular word (maintaining a
line counter as you go).

If your application is interactive where the user will make multiple
queries, you might be better off reading the entire file into a memory
buffer and then parsing it.  If speed and efficiency are not paramount,
then the first approach will probably suffice.

Frank

-----Original Message-----
From: David

Does anyone know how a sequential/linear search is created under a txt
file (to find a specific word line by line).  I have an idea how it is
done using an array, but not under a file.  Any ideas?

Thanks.
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada




^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: sequential search
  2003-03-10 13:09 Beard, Frank Randolph CIV
@ 2003-03-10 17:27 ` Martin Krischik
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Krischik @ 2003-03-10 17:27 UTC (permalink / raw)


> -----Original Message-----
> From: David
> 
> Does anyone know how a sequential/linear search is created under a txt
> file (to find a specific word line by line).  I have an idea how it is
> done using an array, but not under a file.  Any ideas?

Since I had a similar Problem (I needed Search and Replace) I written a
Library to do the job:

http://adacl.sourceforge.net/

If you don't want to do the replace part then just have a Look at
AdaCL-File-Reader-adb to see how the file is read:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/adacl/adacl/Include/AdaCL-SAR-File-ReadTask.ada?rev=HEAD&content-type=text/vnd.viewcvs-markup

From there on it is just normal string manipulation

With Regards

Martin

-- 
Martin Krischik
mailto://Martin@krischik.com
http://ada.krischik.com




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-03-10 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-09 18:08 sequential search David
  -- strict thread matches above, loose matches on Subject: below --
2003-03-10 13:09 Beard, Frank Randolph CIV
2003-03-10 17:27 ` Martin Krischik
     [not found] <87C00083D21D6944A12CB3F8C22DBEEE18821B@NAEAWNYDEX08VA.nadsusea.nads.navy.mil>
2003-03-10 14:13 ` David C. Hoos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox