Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Need assistance using files Posted by tj29 on 15 Dec 2005 at 3:27 PM
My problem is as follows. I have a scanfile function that returns me and integer representing the location of the string if it finds it in the file. My next step is writing a function that will take that integer and return me that entire line in that file not just the string. Is there an algorithm thats fast that I can use. Any help is really appreciated. Thanks.
Report
Re: Need assistance using files Posted by Koppis on 16 Dec 2005 at 12:44 AM
This message was edited by Koppis at 2005-12-16 0:49:31

: My problem is as follows. I have a scanfile function that returns me an integer representing the location of the string if it finds it in the file. My next step is writing a function that will take that integer and return me that entire line in that file not just the string. Is there an algorithm thats fast that I can use. Any help is really appreciated. Thanks.
:

Is filestream too slow for you? I think this would be easy to do using loop that will start from then integer value and loop until end of the file OR end of the line. You have to also read backwards to the end of the previous line OR beginning of the file.

EDIT: Use some kind of buffer if you want to make it faster. Just read 1000 bytes backwards and forwards and start testing, won't be so slow as you could believe it is. Remember to test if that many bytes exist before reading, or you might just write some bug in your program.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.