Procedure

ListTemplateFields

Module

uTemplateFields

Last Modified

3/11/2015 8:41:54 AM

Scope

Interfaced

Declaration

procedure ListTemplateFields(const AText: string; AList: TStrings; ListErrors: boolean = FALSE);

Calls Hierarchy


ListTemplateFields
 └GetTemplateField
   ├LoadTemplateFieldByIEN
   ├LoadTemplateField
   └TTemplateField.Create
     ├TemplateFieldCode2Field
     └TemplateDateCode2DateType

Called-By Hierarchy


                                    ListTemplateFields
                         BoilerplateTemplateFieldsOK┤ 
                           CheckBoilerplate4Fields┤ │ 
                                DoTemplateDialog┤ │ │ 
                    CheckBoilerplate4Fields...┤ │ │ │ 
                             TTemplate.GetText┘ │ │ │ 
                ExecuteTemplateOrBoilerPlate┤   │ │ │ 
                      TfrmDrawers.InsertText┤   │ │ │ 
           TfrmDrawers.tvTemplatesDblClick┤ │   │ │ │ 
            TfrmDrawers.tvTemplatesKeyDown┤ │   │ │ │ 
                TfrmDrawers.NewRECDragDrop┤ │   │ │ │ 
          TfrmDrawers.SetRichEditControl┘ │ │   │ │ │ 
                 TfrmDCSumm.FormCreate┤   │ │   │ │ │ 
               TfrmConsults.FormCreate┤   │ │   │ │ │ 
                TfrmSurgery.FormCreate┤   │ │   │ │ │ 
                  TfrmNotes.FormCreate┘   │ │   │ │ │ 
        TfrmDrawers.mnuInsertTemplateClick┘ │   │ │ │ 
  TfrmDCSumm.popSummMemoInsTemplateClick┤   │   │ │ │ 
TfrmConsults.popNoteMemoInsTemplateClick┤   │   │ │ │ 
 TfrmSurgery.popNoteMemoInsTemplateClick┤   │   │ │ │ 
   TfrmNotes.popNoteMemoInsTemplateClick┘   │   │ │ │ 
         TfrmDrawers.mnuPreviewTemplateClick┤   │ │ │ 
        TfrmDCSumm.popSummMemoPreviewClick┤ │   │ │ │ 
      TfrmConsults.popNoteMemoPreviewClick┤ │   │ │ │ 
       TfrmSurgery.popNoteMemoPreviewClick┤ │   │ │ │ 
         TfrmNotes.popNoteMemoPreviewClick┘ │   │ │ │ 
            TfrmDrawers.mnuCopyTemplateClick┤   │ │ │ 
            TfrmTemplateEditor.mnuBPTryClick┘   │ │ │ 
          TfrmTemplateEditor.tvTreeKeyDown┘     │ │ │ 
                                ShowTemplateData┘ │ │ 
        TfrmDrawers.mnuPreviewTemplateClick...┤   │ │ 
           TfrmTemplateEditor.mnuBPTryClick...┘   │ │ 
                            TdmodShared.TemplateOK┘ │ 
                       TfrmDrawers.InsertText...┤   │ 
          TfrmDrawers.mnuPreviewTemplateClick...┤   │ 
                TfrmDrawers.mnuCopyTemplateClick┤   │ 
         TfrmTemplateEditor.mnuBPErrorCheckClick┘   │ 
              TfrmTemplateEditor.tvTreeKeyDown┤     │ 
           TfrmTemplateEditor.mnuBPTryClick...┘     │ 
                                          AddXMLList┘ 
                                    GetXMLFromWord┤   
       TfrmTemplateEditor.mnuImportTemplateClick┘ │   
                            TTemplate.CanExportXML┘   
                                       ..(rec)..┤     
       TfrmTemplateEditor.mnuExportTemplateClick┘     

Calls

Name Declaration Comments
GetTemplateField function GetTemplateField(ATemplateField: string; ByIEN: boolean): TTemplateField; -

Called-By

Name Declaration Comments
AddXMLList procedure AddXMLList(Data, Fields: TStrings; const Pad: string; FldType: TTemplateExportField; Const Txt: string); -
BoilerplateTemplateFieldsOK function BoilerplateTemplateFieldsOK(const AText: string; Msg: string = ''): boolean; -


Source

785   procedure ListTemplateFields(const AText: string; AList: TStrings; ListErrors: boolean = FALSE);
786   var
787     i, j, k, flen, BadCount: integer;
788     flddesc, tmp, fld: string;
789     TmpList: TStringList;
790     InactiveList: TStringList;
791     FldObj: TTemplateField;
792   
793   begin
794     if(AText = '') then exit;
795     BadCount := 0;
796     InactiveList := TStringList.Create;
797     try
798       TmpList := TStringList.Create;
799       try
800         TmpList.Text := AText;
801         for k := 0 to TmpList.Count-1 do
802         begin
803           tmp := TmpList[k];
804           repeat
805             i := pos(TemplateFieldBeginSignature, tmp);
806             if(i > 0) then
807             begin
808               fld := '';
809               j := pos(TemplateFieldEndSignature, copy(tmp, i + TemplateFieldSignatureLen, MaxInt));
810               if(j > 0) then
811               begin
812                 inc(j, i + TemplateFieldSignatureLen - 1);
813                 flen := j - i - TemplateFieldSignatureLen;
814                 fld := copy(tmp,i + TemplateFieldSignatureLen, flen);
815                 delete(tmp, i, flen + TemplateFieldSignatureLen + 1);
816               end
817               else
818               begin
819                 delete(tmp,i,TemplateFieldSignatureLen);
820                 inc(BadCount);
821               end;
822               if(fld <> '') then
823               begin
824                 if ListErrors then
825                 begin
826                   FldObj := GetTemplateField(fld, FALSE);
827                   if assigned(FldObj) then
828                   begin
829                     if FldObj.Inactive then
830                       InactiveList.Add('  "' + fld + '"');
831                     flddesc := '';
832                   end
833                   else
834                     flddesc := '  "' + fld + '"';
835                 end
836                 else
837                   flddesc := fld;
838                 if(flddesc <> '') and (AList.IndexOf(flddesc) < 0) then
839                   AList.Add(flddesc)
840               end;
841             end;
842           until (i = 0);
843         end;
844       finally
845         TmpList.Free;
846       end;
847       if ListErrors then
848       begin
849         if(AList.Count > 0) then
850           AList.Insert(0, 'The following template fields were not found:');
851         if (BadCount > 0) then
852         begin
853           if(BadCount = 1) then
854             tmp := 'A template field marker "' + TemplateFieldBeginSignature +
855                    '" was found without a'
856           else
857             tmp := IntToStr(BadCount) + ' template field markers "' + TemplateFieldBeginSignature +
858                    '" were found without';
859           if(AList.Count > 0) then
860             AList.Add('');
861           AList.Add(tmp + ' matching "' + TemplateFieldEndSignature + '"');
862         end;
863         if(InactiveList.Count > 0) then
864         begin
865           if(AList.Count > 0) then
866             AList.Add('');
867           AList.Add('The following inactive template fields were found:');
868           FastAddStrings(InactiveList, AList);
869         end;
870         if(AList.Count > 0) then
871         begin
872           AList.Insert(0, 'Text contains template field errors:');
873           AList.Insert(1, '');
874         end;
875       end;
876     finally
877       InactiveList.Free;
878     end;
879   end;