I had a quick look over your code and managed to reproduce the problem 
as you stated, it looks like the create method of your class is not 
being called correctly. Therefore your FMyList is not being initialized 
and this is why you are getting access violations.

HTH
Martin.

Robert Pointon wrote:

>I am trying to create a class that has a tstring list fill internally
>holding a list of names but I get access errors every time I try to add
>to the list.
>
>This is the class code the idea is a value will be passed an the list
>will be filled accordingly;
>
>calling with mlist.MyList:= memo1.Lines; works fine.
>calling with Mlist.Mynum := 99; Access error.
>
><code>
>unit co_InheritProduct;
>
>interface
> uses classes, sysutils;
>type   TInhertProducts = Class(TObject)
>       private
>               FMyList: TStrings;
>                                FMynum: integer;
>               constructor create;
>               procedure SetMyList(const Value: TStrings);
>               procedure Filllist;
>                                procedure SetMynum(const Value:
>integer);
>       public
>               property MyList : TStrings  read FMyList write
>SetMyList;
>               property Mynum : integer read FMynum write SetMynum;
>   end;
>
>implementation
>
>
>
>{ TInhertProducts }
>
>constructor TInhertProducts.create();
>begin
>       inherited ;
>       // Tstringlist NOT TStrings
>       FMyList := TStringlist.Create;
>end;
>
>
>procedure TInhertProducts.Filllist;
>var
>       i : integer;
>begin
>       for i := 1 to 10 do begin
>               FMyList.Add(IntToStr(i));
>       end;
>end;
>
>procedure TInhertProducts.SetMyList(const Value: TStrings);
>begin
>       FMyList := Value;
>end;
>
>procedure TInhertProducts.SetMynum(const Value: integer);
>begin
>       FMynum := Value;
>       Filllist;
>end;
>
>end.
>
></code>
>
>_______________________________________________
>Delphi mailing list -> [email protected]
>http://www.elists.org/mailman/listinfo/delphi
>
>  
>
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to