<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Getting a line from a file' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Getting a line from a file' posted on the 'Delphi and Kylix' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 25 May 2013 05:06:14 -0700</pubDate>
    <lastBuildDate>Sat, 25 May 2013 05:06:14 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Getting a line from a file</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/273216/273216/getting-a-line-from-a-file/</link>
      <description>I have a file scan procedure that returns me a list of integer representing the position of all the times it found the word it was searching for.  what i want to do is that base on that integer to extract the entire line where the word was found and copy it to another file. &lt;br /&gt;
for example&lt;br /&gt;
    the house is blue.&lt;br /&gt;
    the car is yellow.&lt;br /&gt;
    the house is green.&lt;br /&gt;
&lt;br /&gt;
if i search for house it would return 2 integers giving me the position of both "house" what i would like is to extract does two lines and copy them to another file.  &lt;br /&gt;
&lt;br /&gt;
any help will be appreciated. thank you&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/273216/273216/getting-a-line-from-a-file/</guid>
      <pubDate>Wed, 08 Sep 2004 06:07:08 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
    <item>
      <title>Re: Getting a line from a file</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/273216/273229/re-getting-a-line-from-a-file/#273229</link>
      <description>: I have a file scan procedure that returns me a list of integer representing the position of all the times it found the word it was searching for.  what i want to do is that base on that integer to extract the entire line where the word was found and copy it to another file. &lt;br /&gt;
: for example&lt;br /&gt;
:     the house is blue.&lt;br /&gt;
:     the car is yellow.&lt;br /&gt;
:     the house is green.&lt;br /&gt;
: &lt;br /&gt;
: if i search for house it would return 2 integers giving me the position of both "house" what i would like is to extract does two lines and copy them to another file.  &lt;br /&gt;
: &lt;br /&gt;
: any help will be appreciated. thank you&lt;br /&gt;
: &lt;br /&gt;
You can best load the entire file into a stringlist and use it to get the lines. A second stringlist can represent the destination file, and can later be saved onto the disk.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/273216/273229/re-getting-a-line-from-a-file/#273229</guid>
      <pubDate>Wed, 08 Sep 2004 07:41:27 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
    <item>
      <title>RE: I need it for the following</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/273216/273243/re-i-need-it-for-the-following/#273243</link>
      <description>: : I have a file scan procedure that returns me a list of integer representing the position of all the times it found the word it was searching for.  what i want to do is that base on that integer to extract the entire line where the word was found and copy it to another file. &lt;br /&gt;
: : for example&lt;br /&gt;
: :     the house is blue.&lt;br /&gt;
: :     the car is yellow.&lt;br /&gt;
: :     the house is green.&lt;br /&gt;
: : &lt;br /&gt;
: : if i search for house it would return 2 integers giving me the position of both "house" what i would like is to extract does two lines and copy them to another file.  &lt;br /&gt;
: : &lt;br /&gt;
: : any help will be appreciated. thank you&lt;br /&gt;
: : &lt;br /&gt;
: You can best load the entire file into a stringlist and use it to get the lines. A second stringlist can represent the destination file, and can later be saved onto the disk.&lt;br /&gt;
: &lt;br /&gt;
thanks. &lt;br /&gt;
I try that but the problem is that using stringlist is to slow thats why i was using the scanfile procedure that is really fast but it only returns the positon of every time the it finds a word that you are looking for.  the thing is that i need to look in about 100 files (each containing about 1000+ lines) for each line that starts with the word ERROR. for example&lt;br /&gt;
&lt;br /&gt;
ERROR - this is a test&lt;br /&gt;
&lt;br /&gt;
so every line that starts with ERROR i need to put in another file.&lt;br /&gt;
i need something fast i was told that scanning was fast and it is the problem is getting the line out of the file. &lt;br /&gt;
if you can help i will really appreciated&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/273216/273243/re-i-need-it-for-the-following/#273243</guid>
      <pubDate>Wed, 08 Sep 2004 09:30:30 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
    <item>
      <title>Re: RE: I need it for the following</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/273216/273272/re-re-i-need-it-for-the-following/#273272</link>
      <description>: : : I have a file scan procedure that returns me a list of integer representing the position of all the times it found the word it was searching for.  what i want to do is that base on that integer to extract the entire line where the word was found and copy it to another file. &lt;br /&gt;
: : : for example&lt;br /&gt;
: : :     the house is blue.&lt;br /&gt;
: : :     the car is yellow.&lt;br /&gt;
: : :     the house is green.&lt;br /&gt;
: : : &lt;br /&gt;
: : : if i search for house it would return 2 integers giving me the position of both "house" what i would like is to extract does two lines and copy them to another file.  &lt;br /&gt;
: : : &lt;br /&gt;
: : : any help will be appreciated. thank you&lt;br /&gt;
: : : &lt;br /&gt;
: : You can best load the entire file into a stringlist and use it to get the lines. A second stringlist can represent the destination file, and can later be saved onto the disk.&lt;br /&gt;
: : &lt;br /&gt;
: thanks. &lt;br /&gt;
: I try that but the problem is that using stringlist is to slow thats why i was using the scanfile procedure that is really fast but it only returns the positon of every time the it finds a word that you are looking for.  the thing is that i need to look in about 100 files (each containing about 1000+ lines) for each line that starts with the word ERROR. for example&lt;br /&gt;
: &lt;br /&gt;
: ERROR - this is a test&lt;br /&gt;
: &lt;br /&gt;
: so every line that starts with ERROR i need to put in another file.&lt;br /&gt;
: i need something fast i was told that scanning was fast and it is the problem is getting the line out of the file. &lt;br /&gt;
: if you can help i will really appreciated&lt;br /&gt;
: &lt;br /&gt;
The following get procedure is quite slow, but it's easy to program. You open the file as a file of char. Then seek() to the first position of the word error and start to copy it char for char to the other file, until you encounter the #13#10 line ending code. Then you seek() the next position, and start copying. Repeat this seek-copy procedure until all the ERROR-lines are copied.&lt;br /&gt;
Another method, which involves 2 scans of each file is making a map of all the ERROR positions and of all the #13#10 positions. Then you can calculate the length of each ERROR line, and use untyped files and BlockRead()/BlockWrite() to perform the copying. It is more error-prone, but could be faster than the previous method.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/273216/273272/re-re-i-need-it-for-the-following/#273272</guid>
      <pubDate>Wed, 08 Sep 2004 17:10:50 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
    <item>
      <title>thanks that worked fine</title>
      <link>http://www.programmersheaven.com/mb/delphikylix/273216/273308/thanks-that-worked-fine/#273308</link>
      <description>: : : : I have a file scan procedure that returns me a list of integer representing the position of all the times it found the word it was searching for.  what i want to do is that base on that integer to extract the entire line where the word was found and copy it to another file. &lt;br /&gt;
: : : : for example&lt;br /&gt;
: : : :     the house is blue.&lt;br /&gt;
: : : :     the car is yellow.&lt;br /&gt;
: : : :     the house is green.&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : if i search for house it would return 2 integers giving me the position of both "house" what i would like is to extract does two lines and copy them to another file.  &lt;br /&gt;
: : : : &lt;br /&gt;
: : : : any help will be appreciated. thank you&lt;br /&gt;
: : : : &lt;br /&gt;
: : : You can best load the entire file into a stringlist and use it to get the lines. A second stringlist can represent the destination file, and can later be saved onto the disk.&lt;br /&gt;
: : : &lt;br /&gt;
: : thanks. &lt;br /&gt;
: : I try that but the problem is that using stringlist is to slow thats why i was using the scanfile procedure that is really fast but it only returns the positon of every time the it finds a word that you are looking for.  the thing is that i need to look in about 100 files (each containing about 1000+ lines) for each line that starts with the word ERROR. for example&lt;br /&gt;
: : &lt;br /&gt;
: : ERROR - this is a test&lt;br /&gt;
: : &lt;br /&gt;
: : so every line that starts with ERROR i need to put in another file.&lt;br /&gt;
: : i need something fast i was told that scanning was fast and it is the problem is getting the line out of the file. &lt;br /&gt;
: : if you can help i will really appreciated&lt;br /&gt;
: : &lt;br /&gt;
: The following get procedure is quite slow, but it's easy to program. You open the file as a file of char. Then seek() to the first position of the word error and start to copy it char for char to the other file, until you encounter the #13#10 line ending code. Then you seek() the next position, and start copying. Repeat this seek-copy procedure until all the ERROR-lines are copied.&lt;br /&gt;
: Another method, which involves 2 scans of each file is making a map of all the ERROR positions and of all the #13#10 positions. Then you can calculate the length of each ERROR line, and use untyped files and BlockRead()/BlockWrite() to perform the copying. It is more error-prone, but could be faster than the previous method.&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
thanks that worked just fine thanks again&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/delphikylix/273216/273308/thanks-that-worked-fine/#273308</guid>
      <pubDate>Thu, 09 Sep 2004 02:31:57 -0700</pubDate>
      <category>Delphi and Kylix</category>
    </item>
  </channel>
</rss>