Hi,
I am attaching a RTF file , which contains Tags in : <PatientName> this format, which using the following code to replace the PatientName with the actual name in
with ScaleRichView.RichViewEdit do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<PatientName>', [rvseoDown,rvseoWholeWord]) do InsertText(cPatientName);
Format;
end;
Now I have put the tags into the header as in the Attached RTF file. What change needs to be done for the above code to work in the rvheader ?
this change gives error,
with ScaleRichView.RVHeader do begin
Please help.
I Am making changes to the code after a very long time
Search and Replace in RVheader of Scalerichview
Search and Replace in RVheader of Scalerichview
- Attachments
-
- Template - Model.rtf
- (73.21 KiB) Downloaded 3981 times
-
- Site Admin
- Posts: 17553
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Search and Replace in RVheader of Scalerichview
SRV.RVHeader contains header text only when a header is active (i.e., the caret is inside the header).
If the caret is inside the main document, or if the editor is unformatted yet, header text is inside SRV.SubDocuments[].
So you have two options to modify header:
1. Make sure that the header is not active. It may be immediately after calling SRV.Clear or loading a file. If the document is already displayed, call SRV.StartEditing(srvrveMain).
Now you can modify SRV.SubDocuments[]. Items in this property have methods of TRichView, but do not have editing methods.
2. The editor must be formatted. Activate header editing SRV.StartEditing(srvrveHeader). But please note that a document may have several headers (for the first page, for even pages, for other pages).
Now you can edit header using SRV.RVHeader methods. In this mode, it is assumed that you use editing (undoable) methods. If you still want using non-editing methods, when finished, call
If the caret is inside the main document, or if the editor is unformatted yet, header text is inside SRV.SubDocuments[].
So you have two options to modify header:
1. Make sure that the header is not active. It may be immediately after calling SRV.Clear or loading a file. If the document is already displayed, call SRV.StartEditing(srvrveMain).
Now you can modify SRV.SubDocuments[]. Items in this property have methods of TRichView, but do not have editing methods.
2. The editor must be formatted. Activate header editing SRV.StartEditing(srvrveHeader). But please note that a document may have several headers (for the first page, for even pages, for other pages).
Now you can edit header using SRV.RVHeader methods. In this mode, it is assumed that you use editing (undoable) methods. If you still want using non-editing methods, when finished, call
Code: Select all
SRV.RVHeader.ClearUndo;
SRV.RVHeader.Change;
SRV.Format;
-
- Site Admin
- Posts: 17553
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Search and Replace in RVheader of Scalerichview
Your code modifies document using InsertText method. It is an editing method.
So just activate header editing:
Format is not needed after InsertText.
You can change ActiveEditor to RVHeader in this code.
So just activate header editing:
Code: Select all
ScaleRichView.StartEditing(srvrveHeader).
with ScaleRichView.ActiveEditor do
begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<PatientName>', [rvseoDown,rvseoWholeWord]) do
InsertText(cPatientName);
end;
You can change ActiveEditor to RVHeader in this code.
Re: Search and Replace in RVheader of Scalerichview
Thanks sergey, for the fast response. Will implement and get back
Re: Search and Replace in RVheader of Scalerichview
Hello Sergey,
I have coded as advised. Still the tags are not getting replaced. I am not sure what i am doing wrong. The following is code which gets executed
can you please point out what is missing here.
Regards,
Thanks in advance
TransitDataNew.RichViewEdit.Clear;
TransitDataNew.RichViewEdit.LoadRTF(cFileName);
TransitDataNew.Format;
TransitDataNew.StartEditing(srvrveHeader);
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<LabNumber>', [rvseoDown,rvseoWholeWord]) do
InsertText(clabNumber);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<UHID>', [rvseoDown,rvseoWholeWord]) do InsertText(cUHID);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<AdmissionNo>', [rvseoDown,rvseoWholeWord]) do InsertText(cIpCode);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<WardNo>', [rvseoDown,rvseoWholeWord]) do InsertText(cWardNo);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<PatientType>', [rvseoDown,rvseoWholeWord]) do InsertText(cPatientType);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<TypeData>', [rvseoDown,rvseoWholeWord]) do InsertText(cTypeData);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<RoomNo>', [rvseoDown,rvseoWholeWord]) do InsertText(cRoomNo);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<PatientName>', [rvseoDown,rvseoWholeWord]) do InsertText(cPatName);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<GenderAge>', [rvseoDown,rvseoWholeWord]) do InsertText(cGenderAge);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
if lPreFix then
while SearchText('<ReferringDoctor>', [rvseoDown,rvseoWholeWord]) do InsertText('Dr.'+ProperCase(cDocname))
else
while SearchText('<ReferringDoctor>', [rvseoDown,rvseoWholeWord]) do InsertText(''+ProperCase(cDocname));
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<RequestDate>', [rvseoDown,rvseoWholeWord]) do InsertText(cRequestDate);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<CollectionDate>', [rvseoDown,rvseoWholeWord]) do InsertText(cSampleDate);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<Today>', [rvseoDown,rvseoWholeWord]) do
InsertText(FormatdateTime('dd/mm/yyyy hh:mm am/pm',now)); // and Changed to date and time
end;
//TransitDataNew.RVHeader.ClearUndo;
//TransitDataNew.RVHeader.Change;
//TransitDataNew.Format;
//TransitDataNew.AddNL(' Prepared by :'+cFullName,rvsHeading);
TransitDataNew.RichViewEdit.AddNL(' ***** END OF REPORT ****',0);
TransitDataNew.RichViewEdit.AddNL(' Prepared by :'+LowerCase(cFullName),0,0);
//TransitDataNew.AddNL(' ',rvsNormal,0);
TransitDataNew.Format;
I have coded as advised. Still the tags are not getting replaced. I am not sure what i am doing wrong. The following is code which gets executed
can you please point out what is missing here.
Regards,
Thanks in advance
TransitDataNew.RichViewEdit.Clear;
TransitDataNew.RichViewEdit.LoadRTF(cFileName);
TransitDataNew.Format;
TransitDataNew.StartEditing(srvrveHeader);
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<LabNumber>', [rvseoDown,rvseoWholeWord]) do
InsertText(clabNumber);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<UHID>', [rvseoDown,rvseoWholeWord]) do InsertText(cUHID);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<AdmissionNo>', [rvseoDown,rvseoWholeWord]) do InsertText(cIpCode);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<WardNo>', [rvseoDown,rvseoWholeWord]) do InsertText(cWardNo);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<PatientType>', [rvseoDown,rvseoWholeWord]) do InsertText(cPatientType);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<TypeData>', [rvseoDown,rvseoWholeWord]) do InsertText(cTypeData);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<RoomNo>', [rvseoDown,rvseoWholeWord]) do InsertText(cRoomNo);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<PatientName>', [rvseoDown,rvseoWholeWord]) do InsertText(cPatName);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<GenderAge>', [rvseoDown,rvseoWholeWord]) do InsertText(cGenderAge);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
if lPreFix then
while SearchText('<ReferringDoctor>', [rvseoDown,rvseoWholeWord]) do InsertText('Dr.'+ProperCase(cDocname))
else
while SearchText('<ReferringDoctor>', [rvseoDown,rvseoWholeWord]) do InsertText(''+ProperCase(cDocname));
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<RequestDate>', [rvseoDown,rvseoWholeWord]) do InsertText(cRequestDate);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<CollectionDate>', [rvseoDown,rvseoWholeWord]) do InsertText(cSampleDate);
end;
with TransitDataNew.RVHeader do begin
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
while SearchText('<Today>', [rvseoDown,rvseoWholeWord]) do
InsertText(FormatdateTime('dd/mm/yyyy hh:mm am/pm',now)); // and Changed to date and time
end;
//TransitDataNew.RVHeader.ClearUndo;
//TransitDataNew.RVHeader.Change;
//TransitDataNew.Format;
//TransitDataNew.AddNL(' Prepared by :'+cFullName,rvsHeading);
TransitDataNew.RichViewEdit.AddNL(' ***** END OF REPORT ****',0);
TransitDataNew.RichViewEdit.AddNL(' Prepared by :'+LowerCase(cFullName),0,0);
//TransitDataNew.AddNL(' ',rvsNormal,0);
TransitDataNew.Format;
-
- Site Admin
- Posts: 17553
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Search and Replace in RVheader of Scalerichview
Try including "multiitem" option in SearchText parameter. Maybe field codes belong to several text items.
Re: Search and Replace in RVheader of Scalerichview
I got the issue. I should have added SRichViewEdit1.StartEditing(srvrveMain) after the header has been modified and before starting the body editing. Now I can see the changes in the tags which are replaced.
Thanks
Thanks