N
N
Nekit Medvedev2017-06-02 14:23:13
Delphi
Nekit Medvedev, 2017-06-02 14:23:13

I create a text converter from Richedit (properties (bold, italic...) to html code, what's wrong?

procedure TForm4.Button2Click(Sender: TObject);
var
x{счётчик жирных символов},i{строки},j{Символы},n{количество дополнительных символов(теги)}:integer;
begin
x:=-1;
n:=0;
for i := 0 to RichEdit1.Lines.Count-1  do
  for j := 0 to Length(RichEdit1.Lines[i]) do
    begin
    richedit1.SelStart:=j;{фокус на символе}
       label4.caption:=inttostr(n);
       label3.caption:=inttostr(j);
       label5.caption:=inttostr(x);

        if RichEdit1.SelAttributes.Style=[fsBold]{если символ жирный} then
       begin
       x:=x+1;
        if x=0 then
         begin
          memo1.SelStart:=j+n-1;
          memo1.SelText:='<br>';
          n:=n+4;
         end
         else
          if x>0 then
          if RichEdit1.SelAttributes.Style<>[fsBold]{если символ не жирный} then
           begin
            memo1.SelStart:=j+n;
            memo1.SelText:='</br>';
            x:=-1;
            n:=n+5 ;
        end;
       end;

        end;
               label1.caption:=inttostr(x);
          n:=n+1;
        end;

Symptoms: the second condition does not work (if the counter x>0 and the font is not bold) what is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kalapanga, 2017-06-02
@NIKROTOS

There is no need to guess - use debugging! Take a short text as an example and go through these cycles of yours step by step. There you will see why and what condition did not work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question