Procedure

ExpandEmbeddedFields

Module

uTemplates

Last Modified

7/15/2014 3:26:44 PM

Comments

07/26/01  S Monson    Procedure to take a list of fields and expand it with any
                       embedded fields.  Handles embedded field loops
                       (self referencing loops.)

Scope

Interfaced

Declaration

procedure ExpandEmbeddedFields(flds: TStringList);

Calls Hierarchy


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

Called-By Hierarchy


                       ExpandEmbeddedFields
TfrmTemplateEditor.mnuExportTemplateClick┘ 

Calls

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

Called-By

Name Declaration Comments
TfrmTemplateEditor.mnuExportTemplateClick procedure mnuExportTemplateClick(Sender: TObject); -


Source

2771  procedure ExpandEmbeddedFields(flds: TStringList);
2772  {07/26/01  S Monson    Procedure to take a list of fields and expand it with any
2773                         embedded fields.  Handles embedded field loops
2774                         (self referencing loops.)}
2775  var
2776    i,pos1,pos2: integer;
2777    ifield: TTemplateField;
2778    estring,next: string;
2779  begin
2780    if flds.count < 1 then
2781      Exit;
2782    i := 0;
2783    repeat
2784      ifield := GetTemplateField(flds[i],False);
2785      if ifield <> nil then
2786        begin
2787          estring := '';
2788          case ifield.FldType of
2789            dftText,dftComboBox,dftButton,
2790            dftCheckBoxes,dftRadioButtons: estring := ifield.items;
2791            dftHyperlink: estring := ifield.EditDefault;
2792          end;
2793          while (estring <> '') do
2794            begin
2795              pos1 := pos(TemplateFieldBeginSignature,estring);
2796              if pos1 > 0 then
2797                begin
2798                  estring := copy(estring,(pos1 + length(TemplateFieldBeginSignature)),maxint);
2799                  pos2 := pos(TemplateFieldEndSignature,estring);
2800                  if pos2 > 0 then
2801                    begin
2802                      next := copy(estring,1,pos2-1);
2803                      delete(estring,1,pos2-1+length(TemplateFieldEndSignature));
2804                      if flds.IndexOf(next) < 0 then
2805                        flds.add(next);
2806                    end
2807                  else
2808                    estring := '';
2809                end
2810              else
2811                estring := '';
2812            end;
2813          inc(i);
2814        end
2815      else
2816        flds.Delete(i);
2817    until (i > flds.count-1);
2818  end;