Changing variables
Changing variables
Hello Sergey!
I need a formula for SrichView that runs inside the onClick of a button as follows:
1) Find the number of pages
2) Change the variables FiellFields using only the first sheet.
3) performing my procedure of updating of a table.
4) Change the variables FiellFields using only the second page.
5) Run my procedure of updating of a table.
6) Changing the variables FiellFields using only the third leaf.
... and so on until the last page. That is, we have to seek the number of pages, create a While () according to this number, and run the function in FiellFields only selected pages ..
There's how to do this?
I need a formula for SrichView that runs inside the onClick of a button as follows:
1) Find the number of pages
2) Change the variables FiellFields using only the first sheet.
3) performing my procedure of updating of a table.
4) Change the variables FiellFields using only the second page.
5) Run my procedure of updating of a table.
6) Changing the variables FiellFields using only the third leaf.
... and so on until the last page. That is, we have to seek the number of pages, create a While () according to this number, and run the function in FiellFields only selected pages ..
There's how to do this?
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I use the following:
FillFields (SRichViewEdit1.RichViewEdit.RVData);
and
This procedure would have to run on each page separadamnete so I can run other commands to change page ...
FillFields (SRichViewEdit1.RichViewEdit.RVData);
and
Code: Select all
TFrmCadModelos.FillFields procedure (RVData: TCustomRVData);
var i, j, r, c: Integer;
table: TRVTableItemInfo;
FieldName, FieldValue: String;
s: String;
FieldEnd: Integer;
Changed: Boolean;
begin
for i: = 0 to RVData.ItemCount-1
RVData.GetItemStyle if (i) = rvsTable then begin
table: = TRVTableItemInfo (RVData.GetItem (i));
is r: = 0 to table.Rows.Count-1
is c: = 0 to table.Rows [r]. Count-1
table.Cells if [r, c] <> nil then
FillFields (table.Cells [r, c]. GetRVData);
end
RVData.GetItemStyle else if (i)> = 0 then begin
s: = RVData.GetItemText (i);
FieldEnd: = 0;
Changed: = False;
for j: = Length (s) downto 1 do begin
if s [j ]='}' then
FieldEnd: = j
else if (s [j ]='{') and (FieldEnd> 0) then begin
FieldName: = Copy (s, j +1, FieldEnd-j-1);
FieldValue: = GetFieldValueFromDatabase (FieldName);
Delete (s, j, FieldEnd-j +1);
Insert (FieldValue, s, j);
FieldEnd: = 0;
Changed: = True;
end;
end;
if Changed then
RVData.SetItemText (i, s);
end;
end;
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Code: Select all
procedure TForm3.FillFields (RVData: TCustomRVData; srv: TSRichViewEdit;
PageNo: Integer);
var i, j, r, c, FirstItemNo, FirstOffs, LastItemNo, LastOffs,
First, Last: Integer;
table: TRVTableItemInfo;
FieldName, FieldValue: String;
s: String;
FieldEnd: Integer;
Changed: Boolean;
begin
// finding the range of items for processing
if PageNo<>0 then begin
// item range on the page
srv.GetPageStartItemNo(PageNo, FirstItemNo, FirstOffs);
srv.GetPageLastItemNo(PageNo, LastItemNo, LastOffs);
end
else begin
// RVData completely
FirstItemNo := 0;
LastItemNo := RVData.ItemCount-1;
if RVData.GetItemStyle(FirstItemNo)=rvsTable then
FirstOffs := 0
else
FirstOffs := RVData.GetOffsBeforeItem(FirstItemNo);
if RVData.GetItemStyle(LastItemNo)=rvsTable then
LastOffs := TRVTableItemInfo(RVData.GetItem(LastItemNo)).RowCount-1
else
LastOffs := RVData.GetOffsAfterItem(LastItemNo);
end;
// processing
for i := LastItemNo downto FirstItemNo do
if RVData.GetItemStyle(i) = rvsTable then begin
// tables: calling recursively
table := TRVTableItemInfo (RVData.GetItem(i));
if i=FirstItemNo then
First := FirstOffs
else
First := 0;
if i=LastItemNo then
Last := LastOffs
else
Last := table.RowCount-1;
for r := First to Last do
for c := 0 to table.ColCount-1 do
if table.Cells[r, c] <> nil then
FillFields (table.Cells[r, c].GetRVData, srv, 0);
end
else if RVData.GetItemStyle(i) >= 0 then begin
// text
s := RVData.GetItemText (i);
FieldEnd := 0;
Changed := False;
if i=FirstItemNo then
First := FirstOffs
else
First := 1;
if i=LastItemNo then
Last := LastOffs-1
else
Last := Length(s);
for j := Last downto First do begin
if s[j]='}' then
FieldEnd := j
else if (s [j ]='{') and (FieldEnd> 0) then begin
FieldName := Copy (s, j +1, FieldEnd-j-1);
FieldValue := GetFieldValueFromDatabase (FieldName);
Delete (s, j, FieldEnd-j +1);
Insert (FieldValue, s, j);
FieldEnd := 0;
Changed := True;
end;
end;
if Changed then
RVData.SetItemText (i, s);
end;
end;
Code: Select all
FillFields(SRichViewEdit1.RichViewEdit.RVData, SRichViewEdit1, 1);
SRichViewEdit1.Format;
Note 2: I suggest to call this function in backward direction, from SRichViewEdit1.PageCount downto 1.
Note 3: After replacing fields with values, document may be separated to pages in different places.
Note 4: when, in future, we implement page breaks inside table cells for TSRichViewEdit, this code will be not completely correct, because it will be not enough to use GetPageStartItemNo/GetPageLastItemNo to find the first/last row on the page.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Download a newer trial from http://www.trichview.com/download/