Board index » cppbuilder » Re: Richedit and Text file.

Re: Richedit and Text file.


2005-06-01 12:31:52 AM
cppbuilder81
Dwayne wrote:
Quote
I am loading up a Text file in RichEdit. The only problem is, the file in
the window has all the "Formatting" destroyed. It is a pure Text file, and
if I look at it with a text editor, it is perfect.
Well what do you consider a pure tekst file ? What is the extension of the file ?
Which editor did you use ? TRichEdit workst with PlainText files (*.txt) or
the rich text format.(*.rtf).
Hans.
 
 

Re:Re: Richedit and Text file.

"Dwayne" < XXXX@XXXXX.COM >wrote in message
Quote
I am loading up a Text file in RichEdit.
How exactly are you loding the text? If via the RichEdit's LoadFromStream()
or LoadFromFile() methods, what is the value of the PlainText property prior
to loading?
Gambit
 

Re:Re: Richedit and Text file.

Hello Folks,
I am loading up a Text file in RichEdit. The only problem is, the file in
the window has all the "Formatting" destroyed. It is a pure Text file, and
if I look at it with a text editor, it is perfect. If I load it up with
Richedit, the Spaces between the words are destroyed. I have tried changing
the pitches from Normal, to Fixed, to Variable. No luck... Any suggestions?
Dwayne
 

{smallsort}

Re:Re: Richedit and Text file.

"Dwayne" < XXXX@XXXXX.COM >wrote in message
Quote
I am creating the Text file with the following:
Rather than showing the code that producing the text file, why don't you
show what the text file actually look like instead? I don't know what your
data arrays are containing.
Quote
Plain Text can be either true or false... I get the same result.
Well, you are not putting any formatting into the file to begin with, so
what formatting do you think the RichEdit is losing exactly?
Quote
I uploaded a attachment.
I see no such attachment. Where you did you upload it?
Gambit
 

Re:Re: Richedit and Text file.

Hello Gambit,
Gambit>>How exactly are you loding the text? If via the RichEdit's
LoadFromStream()
Quote
or LoadFromFile() methods, what is the value of the PlainText property
prior
to loading?<<
I will try to answer your questions the best I can.
I am using LoadFromFile();
I am creating the Text file with the following:
FILE *out;
out=fopen("data.bak","wt");
sprintf(buf,"%9s%9s%9s%9s%9.0f%9.0f %8.2f %8.2f\n",
Dat[(int)a],Cus[(int)a],Ord[(int)a],Inv[(int)a],
Amo[(int)a],totalboardfeet-Amo[(int)a],
Cos[(int)a],Total-Cos[(int)a]);
fputs(buf,out);
The "\n" is the only "new line" hidden character for ASCII.
I Loop through the sprintf command a certain number of times (between 1 and
100 or so, dependin on requirements).
Then I close the file and do the following:
Form3->RichEdit1->Lines->LoadFromFile("Data.bak");
Plain Text can be either true or false... I get the same result. I
uploaded a attachment.
Dwayne
 

Re:Re: Richedit and Text file.

You might want to set a non-proportional font (like courier) which will make
columns align correctly.
Propotional spaced fonts like Times etc. make spaces quite narrow and so
columns dont line up.
HTH Pete
BTW you are NOT supposed to upload files to these newsgroups.
The binaries newsgroup is where these should be placed.
"Dwayne" < XXXX@XXXXX.COM >wrote in message
Quote
I took a look at my upload, and the outcome of the RichEdit turned out ok,
but my attempt to align the colums like Notepad looks like failed...
 

Re:Re: Richedit and Text file.

"Dwayne" < XXXX@XXXXX.COM >wrote in message
Quote
I believe the RichEdit is losing the "Spaces or Justificatin
that the sprintf is inserting when it justifies with the following:
RichEdit controls do not strip away spaces or justifications.
Quote
It seems they do not allow any uploads to this news group.
Correct. That is what the "borland.public.attachments" newsgroup is for
instead.
Quote
copy/paste produces this:
That data works perfectly fine for me when I load it into a RichEdit with a
fixed-width font, such as "Courier New". All spacing is preserved. If it
doesn't work for you, then something else in your project has to be at
fault. What font settings are you using specifically in the RichEdit?
Gambit
 

Re:Re: Richedit and Text file.

Hello Gambit,
Quote
Rather than showing the code that producing the text file, why don't you
show what the text file actually look like instead? I don't know what
your
data arrays are containing.
Data is pure character data... no numbers.
Gambit>>>Well, you are not putting any formatting into the file to begin
with, so
Quote
what formatting do you think the RichEdit is losing exactly?
I believe the RichEdit is losing the "Spaces or Justificatin that
the sprintf is inserting when it justifies with the following:
sprintf(buf,"%9s%9s%9s%9s%9.0f%9.0f %8.2f %8.2f\n",...Because the data being
saved to the file is perfect, justified, and is exactly what is needed.
Gambit>>I uploaded a attachment.
I see no such attachment. Where you did you upload it?<<
Please accept my apologies... It seems they do not allow any
uploads to this news group. I sent the message with a text attachment to
show the exact data, but I kept receiving "group does not allow attachment
errors" when attempting to upload with attachment. I will do a copy paste
with the data here, but I never have much luck with formatting correctly on
these forums.
copy/paste produces this: (which is all correct data, but skewed from the
original file). NotePad opens it up perfectly, along with all the editors I
have used so far...
08122003 PLUM CR 5-2551 2551 112242 112242 35020.63 35020.63
09022003 LAWRENC 5-2620 164804 3591 108651 1120.43 33900.20
09152003 STOCK 5-2644 165153 17388 91263 5425.23 28474.97
10022003 BIG D 5-2657 165847 8505 82758 2653.65 25821.32
10302003 BIG D L 5-2683 166628 7560 75198 2358.80 23462.53
11032003 BIG D 5-2690 166665 8505 66693 2653.65 20808.88
11122003 BIG D 5-2691 166960 6804 59889 2122.92 18685.97
11192003 BMCW 5-2699 167163 18711 41178 5838.02 12847.95
11192003 BMCW 5-2700 167164 24168 17010 7540.66 5307.29
12092003 BIG D 5-2710 167597 11340 5670 3538.19 1769.10
01152004 FRISCO 5-2749 168281 5670 0 1769.10 0.00
This is how it looks in Notepad (I am hoping this will save and upload
properly,
everything is right justified, thus making even columns on the right side.)
08122003 PLUM CR 5-2551 2551 112242 112242 35020.63 35020.63
09022003 LAWRENC 5-2620 164804 3591 108651 1120.43 33900.20
09152003 STOCK 5-2644 165153 17388 91263 5425.23
28474.97
10022003 BIG D 5-2657 165847 8505 82758 2653.65
25821.32
10302003 BIG D L 5-2683 166628 7560 75198 2358.80
23462.53
11032003 BIG D 5-2690 166665 8505 66693 2653.65
20808.88
11122003 BIG D 5-2691 166960 6804 59889 2122.92
18685.97
11192003 BMCW 5-2699 167163 18711 41178 5838.02
12847.95
11192003 BMCW 5-2700 167164 24168 17010 7540.66
5307.29
12092003 BIG D 5-2710 167597 11340 5670 3538.19
1769.10
01152004 FRISCO 5-2749 168281 5670 0 1769.10
0.00
Dwayne
 

Re:Re: Richedit and Text file.

I believe I got the file to upload on my other try...
It is attached to my other message.. the filename is Data.bak.
simple ASCII. Sorry for my errors.
Dwayne
 

Re:Re: Richedit and Text file.

Hello Pete, Gambit, and others,
Pete>You might want to set a non-proportional font (like courier) which
will make
Quote
columns align correctly.
Propotional spaced fonts like Times etc. make spaces quite narrow and so
columns dont line up.<<
This did the trick...I used Courier Font, and things aligned up
perfectly.
Thank you all for your help, patience, and time.
Dwayne