Using provider mode: TPriceList
2. TPriceList
The implementation of the TPriceList class is simple. An empty list is created in the constructor. The Add method adds a new record and initializes it with specified parameters.
{ TPriceList }
constructor TPriceList.Create;
begin
FRecords := TList.Create;
end;
destructor TPriceList.Destroy;
begin
Clear;
FRecords.Free;
inherited Destroy;
end;
procedure TPriceList.Add(ADescription: string; AOnHand: Integer; APrice: Currency);
var
P: PListEntry;
begin
New(P);
FRecords.Add(P);
P^.Description := ADescription;
P^.OnHand := AOnHand;
P^.Price := APrice;
end;
procedure TPriceList.Clear;
begin
while FRecords.Count > 0 do
begin
Dispose(PListEntry(FRecords[FRecords.Count - 1]));
FRecords.Delete(FRecords.Count - 1);
end;
end;
The next section shows the implementation of the TUserDataSource class.
See Also