Board index » delphi » Word Count etc. in TMemo

Word Count etc. in TMemo

Hi,    
        I have Delphi 1.0 incidentally, hope to get 3 sometime, hence the
referral to both TMemo and TRichEdit....
        Firstly is it possible to use fonts that vary throughout a TMemo
component, rather than having to set the whole lot of text to one font,
and also to print the TMemo contents as the WYSIWYG font styles.

        Secondly is it possible to set word wrap so that when using the print
method and viewing the contents of TMemo or TRichEdit on screen, the
words will actually wrap as WYSIWYG rather than one long line which the
automatic Word Wrap will result in (even though it looks ok on screen).

        Thirdly what is the best way to perform a word count in a TMemo or
TRichEdit component? Is there a quick way that will work without calling
a secondary function? I have a function that should do it, but it keeps
giving me errors when I try and do the following:

IN THE MAIN UNIT:

uses
Wordcoun;

implementation

procedure blah blah blah etc..(It's a TMenuClick call)
begin
ShowMessage('You have "' + WordCount(Memo1.Lines) + '"words');
end;

IN THE FUNCTION UNIT (Wordcoun.pas)

const
function WordCount(s: string): integer;

implementation
function WordCount(s: string): integer;
begin
etc...
end;
end.

        I hope someone, or severalones, can help on this, as its been puzzling
me for a long time and I'm writing my first Delphi program.
        Thanks,
        Nicholas

Feel free to reply by email, but remove the NOSPAM bit from it..!

 

Re:Word Count etc. in TMemo


Nicholas -

 >   Firstly is it possible to use fonts that vary throughout a TMemo
 > component, rather than having to set the whole lot of text to one font,
 > and also to print the TMemo contents as the WYSIWYG font styles.

No. A TMemo is limited to a single font.

 >   Secondly is it possible to set word wrap so that when using the print
 > method and viewing the contents of TMemo or TRichEdit on screen, the
 > words will actually wrap as WYSIWYG rather than one long line which the
 > automatic Word Wrap will result in (even though it looks ok on screen).

Either component should print according to what's on the screen.

 >   Thirdly what is the best way to perform a word count in a TMemo or
 > TRichEdit component? Is there a quick way that will work without calling
 > a secondary function? I have a function that should do it, but it keeps
 > giving me errors when I try and do the following:

There's no word count function for either of these Windows controls.
Nor is there any Delphi method added the their wrappers to perform
this function. Sorry.

Good luck.

Kurt

Other Threads