Changeset 30 for trunk/UCore.pas


Ignore:
Timestamp:
Nov 24, 2021, 8:42:24 PM (3 years ago)
Author:
chronos
Message:
  • Added: In case of loading errors show a list of found errors with line numbers.
  • Fixed: Check if property block started correctly.
  • Added: More standard properties.
  • Fixed: Improved alignment of fields in contact dialog.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r29 r30  
    6868    InitializeStarted: Boolean;
    6969    InitializeFinished: Boolean;
     70    LoadErrors: string;
    7071    procedure FileModified(Sender: TObject);
    7172    function FindFirstNonOption: string;
     
    7374    procedure LoadConfig;
    7475    procedure SaveConfig;
     76    procedure DoError(Text: string; Line: Integer);
    7577  public
    7678    DefaultDataFileClass: TDataFileClass;
     
    9799uses
    98100  UFormMain, UFormSettings, UContact, UFormContacts, UFormFindDuplicity,
    99   UFormGenerate;
     101  UFormGenerate, UFormError;
    100102
    101103resourcestring
     
    104106  SFileNotFound = 'File ''%s'' not found.';
    105107  SMergedContacts = 'Contacts merged. Loaded: %d, New: %d, Updated: %d';
     108  SLine = 'Line %d: %s';
    106109
    107110{ TMergeResult }
     
    310313    if FileClosed then begin
    311314      FileNew;
     315      LoadErrors := '';
    312316      DataFile.LoadFromFile(FileName);
    313317      LastOpenedList1.AddItem(FileName);
     318      if LoadErrors <> '' then begin
     319        FormError := TFormError.Create(nil);
     320        FormError.MemoErrors.Text := LoadErrors;
     321        FormError.ShowModal;
     322        FreeAndNil(FormError);
     323      end;
    314324    end;
    315325  end else ShowMessage(Format(SFileNotFound, [FileName]));
     
    379389    DataFile := DefaultDataFileClass.Create;
    380390    DataFile.OnModify := FileModified;
     391    TContactsFile(DataFile).OnError := DoError;
    381392  end;
    382393end;
     
    437448end;
    438449
     450procedure TCore.DoError(Text: string; Line: Integer);
     451begin
     452  LoadErrors := LoadErrors + Format(SLine, [Line, Text]) + LineEnding;
     453end;
     454
    439455procedure TCore.UpdateInterface;
    440456begin
Note: See TracChangeset for help on using the changeset viewer.