Why doesn't this code wrok?


[ Related Articles and Replies ] [ DelphiLand FAQ ] [ Delphi Tutorials ]

Posted by Rbrrneck on July 01, 2002 at 14:46:44:


I use this code for color syntaxing.
Just drop a Richedit and button on a form and put this code. Oh yeah, put some of the words in the array in the richedits text.
Here's the code:

const
  red: array[0..1] of String = ('var', 'const'); 
procedure TForm1.Button1Click(Sender: TObject);
var 
  i,i2,i3,i4,i5,i6:integer;
begin
  for i:=0 to Richedit1.lines.count-1 do begin
    for i2:=0 to High(red) do begin
      i3:=0;
      i4:=ansipos(red[i3],Richedit1.lines[i3]);
      i5:=Length(red[i3]);
      Richedit1.selstart:=i4-1;
      Richedit1.sellength:=i5;
      Richedit1.Selattributes.Color:=clred;
      i4:=0;
      i5:=0;
    end;
  end;
end; 

Related Articles and Replies:


[ Related Articles and Replies ] [ DelphiLand FAQ ] [ Delphi Tutorials ]