My merge forms consists of tables and multi-line merge fields are often the only item in a cell, so when I do a DeleteItems the ItemNo = -1, so I changed SafeDeleteItems to
else
ItemNo := 0
That seems to work. Any suggestions?
SafeDeleteItem when only 1 item in cell
-
- Posts: 206
- Joined: Thu Sep 15, 2005 1:41 am
- Location: California
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 206
- Joined: Thu Sep 15, 2005 1:41 am
- Location: California
No - Called DeleteItems(0,1)
ItemNo = 0 when I call SafeDeleteItem, because there is only one item, so the dec(ItemNo) line in SafeDeleteItem made it -1. So then the If... is not true, so I added an else to set it to 0.
I believe the ItemNo = 0 is correct because its a zero based array with one item. See my else below.
procedure TLetterMergeForm.SafeDeleteItem(RVData: TCustomRVData; var ItemNo: Integer);
var BR, PB, PS: Boolean;
begin
PS := RVData.IsParaStart(ItemNo);
BR := RVData.IsFromNewLine(ItemNo) and not PS;
PB := RVData.PageBreaksBeforeItems[ItemNo];
RVData.DeleteItems(ItemNo, 1);
dec(ItemNo);
if (ItemNo<RVData.ItemCount) and (ItemNo>=0) then
begin
RVData.GetItem(ItemNo).SameAsPrev := not PS;
RVData.GetItem(ItemNo).BR := BR;
RVData.GetItem(ItemNo).PageBreakBefore := PB;
end else
ItemNo := 0;
end;
I believe the ItemNo = 0 is correct because its a zero based array with one item. See my else below.
procedure TLetterMergeForm.SafeDeleteItem(RVData: TCustomRVData; var ItemNo: Integer);
var BR, PB, PS: Boolean;
begin
PS := RVData.IsParaStart(ItemNo);
BR := RVData.IsFromNewLine(ItemNo) and not PS;
PB := RVData.PageBreaksBeforeItems[ItemNo];
RVData.DeleteItems(ItemNo, 1);
dec(ItemNo);
if (ItemNo<RVData.ItemCount) and (ItemNo>=0) then
begin
RVData.GetItem(ItemNo).SameAsPrev := not PS;
RVData.GetItem(ItemNo).BR := BR;
RVData.GetItem(ItemNo).PageBreakBefore := PB;
end else
ItemNo := 0;
end;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
The line dec(ItemNo) must be removed.
When you delete the ItemNo-th item, the next item (if it exists) becomes the ItemNo-th item, and you should change its properties, not properties of the previous item.
As for value of ItemNo parameter after existing this procedure, it depends on your needs (probably ItemNo should not be a var-parameter at all)
When you delete the ItemNo-th item, the next item (if it exists) becomes the ItemNo-th item, and you should change its properties, not properties of the previous item.
As for value of ItemNo parameter after existing this procedure, it depends on your needs (probably ItemNo should not be a var-parameter at all)