Changeset 5 for trunk/Car.pas


Ignore:
Timestamp:
Jul 8, 2024, 11:31:59 PM (5 months ago)
Author:
chronos
Message:
  • Added: Show source tab with source text which is automatically loaded on start and saved on close.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Car.pas

    r4 r5  
    9898    destructor Destroy; override;
    9999    procedure LoadFromFile(FileName: string);
     100    procedure LoadFromStrings(Lines: TStrings);
    100101    function Print: string;
    101102    property OnLog: TLogEvent read FOnLog write FOnLog;
     
    388389procedure TSummary.LoadFromFile(FileName: string);
    389390var
    390   I: Integer;
    391391  Lines: TStringList;
     392begin
     393  Lines := TStringList.Create;
     394  try
     395    Lines.LoadFromFile(FileName);
     396    LoadFromStrings(Lines);
     397  finally
     398    Lines.Free;
     399  end;
     400end;
     401
     402procedure TSummary.LoadFromStrings(Lines: TStrings);
     403var
     404  I: Integer;
    392405  Line: string;
    393406  CarComparer: TCarComparer;
     
    426439  TableLineCellSeparator = '||';
    427440begin
    428   Lines := TStringList.Create;
    429   Lines.LoadFromFile(FileName);
    430441  for I := 0 to Lines.Count - 1 do begin
    431442    Line := Lines[I];
     
    539550  SaveAndFreeCar(CarName, EngineType, CompanyName, Distance, Odometer, Price,
    540551    PriceWithFuel, RentTime, Consumption);
    541   Lines.Free;
    542552  CarComparer := TCarComparer.Create;
    543553  Cars.Sort(CarComparer);
Note: See TracChangeset for help on using the changeset viewer.