[fpc-pascal] Freepascal and good usage of TStringList

Martin Smat martin.smat at tiscali.cz
Mon Jul 25 20:03:21 CEST 2005


Jean-Marc Chourot wrote:

>Dear All,
>Could any one help me debug the little piece of code thereafter ? I get a
>SIGSEGV.. and I don't know why (OK.. i am not that good).
>Thanks for your help.
>
>JM
>*****************************
>Program TestStringList;
>
>Uses
> CLasses;
>
> var TheStringList:TStringList;
>
> Procedure PopulateList(var Mylist :TstringList);
> var StringlistLocal:TStringList;
>
> begin
>  StringlistLocal.create;
>  StringlistLocal.add('This is a sample Text');
>  StringlistLocal.add('This is a second sample Text');
>  StringlistLocal.add('This is a third sample Text');
> Mylist.Assign( StringlistLocal );
>   StringlistLocal.destroy;
> end;
>
> Function CleanList(  EnterList:TstringList ;   var Outlist
>:TstringList):boolean;
>
>var i: integer;
> begin
>   For i:=0 to EnterList.Count-1 do Outlist.add( EnterList[i]);
> end;
>
> Procedure CallList( Var CleanedList:Tstringlist);
>
> var List0,list1 : Tstringlist;
> Foo: boolean;
> begin
> List0.create;
> //  Here I get a SIGSEGV
>  
>
Use List0 := TStringList.Create;

> List1.create;
>  
>
List1 := TStringList.Create;

Martin.

> Populatelist(list0);
> foo := CleanList(List0,list1);
> CleanedList.assign(List1);
> List0.destroy;
> List1.destroy;
> end;
>
>
> begin
>  TheStringList.create;
>  CallList(TheStringList);
> end.
>
>*************************
>
>
>_______________________________________________
>fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>  
>





More information about the fpc-pascal mailing list