Page 1 of 1

Listindex out of bound

Posted: Thu Feb 05, 2009 7:34 pm
by rijnbeek
When I add an .rvf file at the end of the current rvf i sometimes get a listindex out of bound error at the line:

2027 OnNonText(TRVRectItemInfo(li), dli); in the unit CRVFDATA

What can be the problem?

Posted: Fri Feb 06, 2009 2:48 pm
by proxy3d
How you add RVF a file in the end? You can give an example a code?

Posted: Sat Feb 07, 2009 12:20 pm
by rijnbeek
Here is the code I use. The problems seems to occur when I fill the labelitems with tekst from a database??

Code: Select all

     with SRichViewEdit1 do
            begin
              //move to the end of document
              ItemNo := RichViewEdit.ItemCount-1;
              if ItemNo<>-1 then
              begin
                Offs   := RichViewEdit.GetOffsAfterItem(ItemNo);
                RichViewEdit.SetSelectionBounds(ItemNo,Offs,ItemNo,Offs);
              end;
              RichViewEdit.InsertRVFFromFileEd(FileName);
              FillFields(RichViewEdit.RVData);
              //move to the end of document
              ItemNo := RichViewEdit.ItemCount-1;
              if ItemNo<>-1 then
              begin
                Offs   := RichViewEdit.GetOffsAfterItem(ItemNo);
                RichViewEdit.SetSelectionBounds(ItemNo,Offs,ItemNo,Offs);
              end;
            end;



procedure FillFields(RVData: TCustomRVData);
var i,r,c: Integer;
    table: TRVTableItemInfo;
    FieldName: String;
begin
  for i := 0 to RVData.ItemCount-1 do
    case RVData.GetItemStyle(i) of
      rvsLabel:
        begin
          FieldName := PChar(RVData.GetItemTag(i));
          if IsFieldCode(FieldName) and (pos('<',TRVLabelItemInfo            (RVData.GetItem(i)).Text)<>0) then
          begin
            TRVLabelItemInfo(RVData.GetItem(i)).Text := GetFieldValueFromDatabase(FieldName, True);
            TRVLabelItemInfo(RVData.GetItem(i)).ApplyStyleConversion(RVData,i,2);
          end;
        end;
    end;
end;

Posted: Mon Feb 09, 2009 12:12 am
by proxy3d
Error only at use SRV? If you use TRichViewEdit instead of TSRichViewEdit this error repeats?

Try to switch off before filling of fields updating at SRV:

Code: Select all

SRV.CanUpdate := False;
....
SRV.CanUpdate := True;

Posted: Mon Feb 09, 2009 10:39 pm
by rijnbeek
I tried to add CanUpdate suggestion but it still gave the error.

Your other suggestions I could not try because i have to change the complete editor code.

It seems to happen when I open another setlists with more songs than used the previous time I openend the EditorFOrm. That sounds like the items in the form are still present and not deleted??!!

Should the items added to the form be cleared when the form is closed?? can that be the problem maybe??

Posted: Tue Feb 10, 2009 10:56 am
by proxy3d
If to replace SRV on RichViewEdit in RichViewEdit the problem repeats?

Posted: Tue Feb 10, 2009 3:16 pm
by Sergey Tkachenko
I can see the following problems:
1) Since FillFields modify the document using non-editing methods (such as assignment to LabelItem.Text), Format method must be called after it.
2) Item.ApplyStyleConversion is not supposed to be called directly, not the conversion you expect may be applied.

I am still not sure if the is the reason of this problem.