[fpc-pascal] Freepascal and good usage of TStringList

Jean-Marc Chourot jeanmarc.chourot at free.fr
Mon Jul 25 19:11:48 CEST 2005


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
 List1.create;
 Populatelist(list0);
 foo := CleanList(List0,list1);
 CleanedList.assign(List1);
 List0.destroy;
 List1.destroy;
 end;


 begin
  TheStringList.create;
  CallList(TheStringList);
 end.

*************************





More information about the fpc-pascal mailing list