RichEdit bug
Below is the code where the bug is and the solution I propose.
If the length of variable name is equal to it's value minus 1 then the procedure ends prematurely.
If the length of variable name is equal to it's value minus 1 then the procedure ends prematurely.
procedure TfrRichView.GetRichData(lnum: Integer);
var
 i, j, sum: Integer;
 s, s1, s2: String;
begin
 s := SRichEdit.Lines[lnum];
 sum := 0;
 for i := 0 to lnum - 1 do
 begin
  j := Length(SRichEdit.Lines[i]);
  sum := sum + j + 2;
 end;
 i := 1;
 repeat
  while (i < Length(s)) and (s[i] <> '[') do Inc(i);
  s1 := GetBrackedVariable(s, i, j);
  if i <> j then
  begin
   Delete(s, i, j - i + 1);
   s2 := '';
   CurReport.InternalOnGetValue(s1, s2);
   SRichEdit.SelStart := sum + i - 1;
   SRichEdit.SelLength := j - i + 1;
   SRichEdit.SelText := s2;
   Insert(s2, s, i);
   Inc(i, Length(s2));
  end;
 until i >= Length(s);
 //until i = j;
end;