Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error reading a line from text file - 4096 limit? 2

Status
Not open for further replies.

JustinWillis

IS-IT--Management
Feb 6, 2003
21
GB
Hi, I am having problems reading from a text file that I am creating, it saves a string which is greater than 4096 in length to a line in a text file, but when I go to read it back into a string it only retrieves the first 4096 characters of it?

I am using TRichedit.lines.add('...') and then TRichedit.lines.savetofile('...'), looking at it in notepad it all looks fine, all the data is on the first line etc... then I use TRichedit.lines.loadfromfile('...') and see that all the data has been loaded BUT when I TString := TRichedit.lines[0] only the first 4096 chars are copied to the string.

I assume this is a limit of the string but I don't get why it lets me add more than 4096 to the line in the first place when it can't read it back?? anyone come accross this problem or know how to get around it?

Spreading the data accross multiple lines really isn't desired as it will slow down a speed critical app, any help would be much appreciated, I imagine there is a really simple solution that I am not seeing!

Apologies if i'm being stupid and wasting your time,
Thanks in advance,
Justin Willis.
 
explain this further, post some of the code which saves the text to, but i need a further explanation, first of all, check the rtichtext property (assuming u have a richtext control on), PLAINTEXT is true or false, i think the propertyt is plaintext or richtext or something , if plain text = true then it means its only plain text, if its false then its richtext,

i suggest u do this, save the text as richtext and use a richtext control to read it in, the memo control is limited, but you can make the memo cntrol unlimited usin this methot

SENDMESSAGE(memo1.handle,EXLIMITTEXT,0,999999999);

do this on the form create event, hope this helps.

also if i have not answered corect, explain ur prob further, and dont forget to thank me. :) and u can giv me credit in ur app if u wunt too,. lol.
 
its actually EM_EXLIMITTEXT so do this

SENDMESSAGE(memo1.handle,EM_EXLIMITTEXT,0,999999999); i think this gives u a max of at least 800 megabytes in memory, lol more than enough
 
Hi Abbas, thanks for your response, Delphi spits EM_EXLIMITTEXT back at me so I will try to get it working.

To see what i'm going on about try the following...
1. have a form with 2 TRichedits say Data1 and Data2 (doesn't make a difference whether plaintext or not unfortunalty)
2. at design time put more than 4096 chars of data on the first line of Data1, then have a button which copies the line to the second trichedit Data2 example of how i'm doing this: Data2.lines.add(Data1.lines[0]);
3.run the app and click the button, only the first 4096 chars make it to the second trichedit, the rest is truncated ;-(

what you suggested may be the solution but doesn't seem to like EM_EXLIMITTEXT very much

Thanks for your help,
Justin Willis
 
Justin

I once had the same problem, tried a lot of settings and kludges, but to no avail. If you just need the data in a string do as did

var
tf: TextFile;
s: string;

AssignFile(tf,YourFileName);
Reset(tf);
ReadLn(tf,s);
CloseFile(tf);

s will have the entire line here.

HTH,
Porteiro


 
Thanks Porteiro, I will try that now, Abbas thanks for your help also, btw I had to change the message to EM_LIMITTEXT with Delphi 5 Pro, (still didn't work though but worth a try huh).
 
Cool, many thanks, don't know why I didn't think of that! been coding too long I think.

Thanks guys.
JW.
smiletiniest.gif
 
o i see, i thot u meant the whole textbox not just a single, line, hmmmmm interesting, i never tried that before lol, well if u get the solution post back up here wot u done, ill try soem research too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top