Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2006, 05:40 PM
GAA GAA is offline
Member
 
Join Date: Mar 2004
Posts: 69
Default How to read text file formatted in wordpad?

I have a text file (Test.txt) formatted in word pad. When I read it I cannot get the correct possition of each character because sometimes it change. But I tried to format the text file in notepad the possition of its contents are consistent. Are there any possible way to read my data consistently from my text file formatted in Wordpad? Please refer on my current code bellow.

Thanks in advance.


procedure ReadTextFile;
var

varTextContents : String;
i : Integer;
oFile : TStringlist;
CurrentLine : String;
begin

oFile := TStringlist.Create;

//Read and load the whole file once.
oFile.LoadFromFile('C:\Export\Test.txt');
//count the number of lines....
for i:=0 to oFile.Count-1 do
begin

//Get the data from 0 to 459
CurrentLine := Copy(oFile[i],0, 459);
with dmDTLJV do
begin

{Read the contents of files based on the possition assigned}

end;
end;
end;

oFile.Free;

end;
Reply With Quote
  #2  
Old 01-02-2006, 09:46 PM
gLes gLes is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,273
Default RE: How to read text file formatted in wordpad?

Text files (*.txt) do not contain any formatting and positioning information, you can only position text by adding sufficient space and tab characters, on the other hand you can save your files from WordPad into Rich Text Format (*.rtf) which conserves formatting and positioning information. In Delphi you can use the TRichEdit component to view these files, you can load them like this:

[delphi]Richedit1.Lines.LoadFromFile('filename.rtf');[/delphi]

Hope that helps...

gLes
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 07:04 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.