Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
im trying to create a parser for excel to generate a pricelist from a csv file.
Im doing this with a parser and a generator. To get all the devices containered, i've created a device object and want to list the accessories in it but i have a problem.

Delphi
unit Device;

interface
  uses
    Sysutils, System.Generics.Collections;

  type
  TDevices = class
    DeviceName : string;
  private
    { Private-Deklarationen }
  public
    AList: TList<TDictionary<string, string>>;
    procedure SetDeviceName(Device : string);
    procedure AddAccessories(Name : string; Description: string; Price: string; OType:string);
  end;
var
  Name: string;

implementation

{ Devices }

procedure TDevices.AddAccessories(Name, Description, Price, OType: string);
begin
  AList.Add(TDictionary<string, string>.Create());
  AList[AList.Count-1].Add('name', Name);
  AList[AList.Count-1].Add('description', Description);
  AList[AList.Count-1].Add('price', Price);
  AList[AList.Count-1].Add('type', OType);
end;

procedure TDevices.SetDeviceName(Device: string);
begin
  Name:=Device;
  AList := TList<TDictionary<string, string>>.Create();

end;

end.


I call the
Delphi
TDevices.AddAccessories
in a
Delphi
for
statement. The first run is ok an there is no error. But when
Delphi
TDevices.AddAccessories
is getting called the 2nd time, i get an access violation error. Can anyone help me?

Sorry for my bad english, im from switzerland :)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900