How to construct a list of integers with TList functionality? lazarus / 61-Beginners ---------------------------------------------------------------------- py2pa · 2014-08-17 12:10 I want to construct a list of integers, but not as an simple array. I want my list to have the full functionality that TLists provide (inserting and moving elements etc). How can I do that? Because, if I declare my list as: Code: [Select]my_list: TList; and then give something like this: Code: [Select]my_list.Add(1); the compiler throws the error "pointer expected". Please help. ---------------------------------------------------------------------- MichaelBM · 2014-08-17 12:14 You need to create the list before using the method Add(). my_list.Create; my_list.Add('1'); ---------------------------------------------------------------------- py2pa · 2014-08-17 12:18 I have created it, just ommitted the line. Also, if I pass the number as a string to Add method ('1'), I get the same error ("expected Pointer'). ---------------------------------------------------------------------- marcov · 2014-08-17 12:32 Afaik unit fgl contains a generic version of Tlist, TList<> ---------------------------------------------------------------------- Leledumbo · 2014-08-17 13:16 Quote from: py2pa on August 17, 2014, 02:10:01 pmthe compiler throws the error "pointer expected". Please help. TList is a list of pointer. Specialize TFPGList with integer and use that instead. Quote from: MichaelBM on August 17, 2014, 02:14:06 pmYou need to create the list before using the method Add(). my_list.Create; my_list.Add('1'); 2 mistakes: constructor result is assigned to the variable that will hold it, not called with the variable itselfwith TList, it will still generate "pointer expected" error ---------------------------------------------------------------------- py2pa · 2014-08-17 14:13 Yes, it worked fine with TFPGList. Thank you all.