Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Thread Tools Display Modes
Old 01-02-2006, 05:40 PM
GAA GAA is offline
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;

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

oFile := TStringlist.Create;

//Read and load the whole file once.
//count the number of lines....
for i:=0 to oFile.Count-1 do

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

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



Reply With Quote
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:


Hope that helps...

Reply With Quote

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 09:53 PM.

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