WPCubed Product Support

To get the number of characters in body

Hi Julian,
I want to get the number of characters in the body when a document is opened or closed. Is there a property available or Should I select all the body to get the length?

thank you.

#1 ♥ 0
4.7k Views 3 users read 1 min

Take a look at the wpdocpropdlg.pas unit. There you will find how to count the characters, including or excluding blanks.

#2 ♥ 0
support

The simplest count method is
GetTextLen

if you need something spacial create a loop over all paragraphs and count the characters in a loop:

par := WPRichText.BodyText.FirstPar;
while par<>nil do 
begin
  for i := 0 to par.CharCount-1 do
  begin
    if not par.IsSpace(i) then inc(count);
  end;
  par := par.next;
end;

the above ignores space when counting.

#3 ♥ 0
This category is archived. No new posts are possible.