Procedure

TTemplate.UpdateImportedFieldNames

Module

uTemplates

Last Modified

7/15/2014 3:26:44 PM

Visibility

Public

Owner

TTemplate

Declaration

procedure UpdateImportedFieldNames(List: TStrings);

Calls Hierarchy


TTemplate.UpdateImportedFieldNames
 ├TTemplate.GetBoilerplate
 │ └GetTemplateBoilerplate
 ├TTemplate.CanModify
 │ ├TTemplate.ValidID
 │ └LockTemplate
 ├TTemplate.GetItems
 │ └ExpandTemplate
 │   ├TTemplate.GetChildren
 │   ├GetTemplateChildren
 │   ├AddTemplate
 │   │ ├TTemplate.Create
 │   │ │ └TTemplate.ReminderDialogIEN
 │   │ └TTemplate.AddChild
 │   │   └TTemplate.GetItems...
 │   └TTemplate.ItemIENs
 │     └TTemplate.GetItems...
 └..(rec)..

Called-By Hierarchy


           TTemplate.UpdateImportedFieldNames
                                  ..(rec)..┤ 
  TfrmTemplateEditor.mnuImportTemplateClick┘ 

Calls

Name Declaration Comments
TTemplate.CanModify function CanModify: boolean; -
TTemplate.GetBoilerplate function GetBoilerplate: string; -
TTemplate.GetItems function GetItems: TList; -
TTemplate.UpdateImportedFieldNames procedure UpdateImportedFieldNames(List: TStrings); -

Called-By

Name Declaration Comments
TfrmTemplateEditor.mnuImportTemplateClick procedure mnuImportTemplateClick(Sender: TObject); -
TTemplate.UpdateImportedFieldNames procedure UpdateImportedFieldNames(List: TStrings); -


Source

2483  procedure TTemplate.UpdateImportedFieldNames(List: TStrings);
2484  const
2485    SafeCode = #1 + '^@^' + #2;
2486    SafeCodeLen = length(SafeCode); 
2487  
2488  var
2489    i, p, l1: integer;
2490    Tag1, Tag2, tmp: string;
2491    First, ok: boolean;
2492  
2493  begin
2494    GetBoilerplate;
2495    ok := TRUE;
2496    First := TRUE;
2497    for i := 0 to List.Count-1 do
2498    begin
2499      if(Piece(List[i],U,2) = '0') then
2500      begin
2501        Tag1 := TemplateFieldBeginSignature + Piece(List[i],U,1) + TemplateFieldEndSignature;
2502        Tag2 := TemplateFieldBeginSignature + SafeCode + Piece(List[i],U,3) + TemplateFieldEndSignature;
2503        l1 := length(Tag1);
2504        repeat
2505          p := pos(Tag1, FBoilerplate);
2506          if(p > 0) then
2507          begin
2508            if First then
2509            begin
2510              ok := CanModify;
2511              First := FALSE;
2512            end;
2513            if ok then
2514            begin
2515              tmp := copy(FBoilerplate,1,p-1) + Tag2 + copy(FBoilerplate,p+l1, MaxInt);
2516              FBoilerplate := tmp;
2517            end
2518            else
2519              p := 0;
2520          end;
2521        until (p = 0);
2522      end;
2523      if not ok then break;
2524    end;
2525    if ok then
2526    begin
2527      repeat
2528        p := pos(SafeCode, FBoilerplate);
2529        if(p > 0) then
2530          delete(FBoilerplate, p, SafeCodeLen);
2531      until (p = 0);
2532      GetItems;
2533      for i := 0 to FItems.Count-1 do
2534        TTemplate(FItems[i]).UpdateImportedFieldNames(List);
2535    end;
2536  end;