Listindex out of bound

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
rijnbeek
Posts: 6
Joined: Tue Sep 09, 2008 7:05 pm

Listindex out of bound

Post 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?
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post by proxy3d »

How you add RVF a file in the end? You can give an example a code?
rijnbeek
Posts: 6
Joined: Tue Sep 09, 2008 7:05 pm

Post 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;
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post 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;
rijnbeek
Posts: 6
Joined: Tue Sep 09, 2008 7:05 pm

Post 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??
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post by proxy3d »

If to replace SRV on RichViewEdit in RichViewEdit the problem repeats?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Post Reply