wizard699 Active Member Licensed User Longtime User Jun 27, 2015 #1 Erel, there is a bug in method Add of a List.... or I'm crazy. This is an example .... m is a Map object, filled with some record from a table. l_subcat is a List object For Row = 0 To RowNumber - 1 Cursor1.Position = Row 'set the Cursor to each row m.Put("id_cat_subcat", Cursor1.GetString("cat_subcat.id_cat_subcat") ) m.Put("desc_subcategoria", Cursor1.GetString("subcategorie.desc_subcategoria") ) l_subcat.Add(m) Next m change on every for cycle. But ... the method Add seems to substitute (at every execution) all the item yet inserted ... with the last map object added. Is it possible? I've noticed the problem adding a map object. It's a bug? Or I'm wrong something? At the end of the Fro cycle, all the item in the List object are the same ...
Erel, there is a bug in method Add of a List.... or I'm crazy. This is an example .... m is a Map object, filled with some record from a table. l_subcat is a List object For Row = 0 To RowNumber - 1 Cursor1.Position = Row 'set the Cursor to each row m.Put("id_cat_subcat", Cursor1.GetString("cat_subcat.id_cat_subcat") ) m.Put("desc_subcategoria", Cursor1.GetString("subcategorie.desc_subcategoria") ) l_subcat.Add(m) Next m change on every for cycle. But ... the method Add seems to substitute (at every execution) all the item yet inserted ... with the last map object added. Is it possible? I've noticed the problem adding a map object. It's a bug? Or I'm wrong something? At the end of the Fro cycle, all the item in the List object are the same ...
DonManfred Expert Licensed User Longtime User Jun 27, 2015 #3 wizard699 said: Cursor1.Position = Row 'set the Cursor to each row m.Put("id_cat_subcat", Cursor1.GetString("cat_subcat.id_cat_subcat") ) m.Put("desc_subcategoria", Cursor1.GetString("subcategorie.desc_subcategoria") ) l_subcat.Add(m) Click to expand... add a DIM for each iteration for the map.... Code: Copy Cursor1.Position = Row 'set the Cursor to each row dim m as map m.initialze m.Put("id_cat_subcat", Cursor1.GetString("cat_subcat.id_cat_subcat") ) m.Put("desc_subcategoria", Cursor1.GetString("subcategorie.desc_subcategoria") ) l_subcat.Add(m)
wizard699 said: Cursor1.Position = Row 'set the Cursor to each row m.Put("id_cat_subcat", Cursor1.GetString("cat_subcat.id_cat_subcat") ) m.Put("desc_subcategoria", Cursor1.GetString("subcategorie.desc_subcategoria") ) l_subcat.Add(m) Click to expand... add a DIM for each iteration for the map.... Code: Copy Cursor1.Position = Row 'set the Cursor to each row dim m as map m.initialze m.Put("id_cat_subcat", Cursor1.GetString("cat_subcat.id_cat_subcat") ) m.Put("desc_subcategoria", Cursor1.GetString("subcategorie.desc_subcategoria") ) l_subcat.Add(m)
DonManfred Expert Licensed User Longtime User Jun 27, 2015 #4 wizard699 said: At the end of the Fro cycle, all the item in the List object are the same ... Click to expand... It is because you dimmed it ONCE and always adding the same object instead of adding a new one each time. In fact you are adding references to the same object. All references of this object will have the same content.
wizard699 said: At the end of the Fro cycle, all the item in the List object are the same ... Click to expand... It is because you dimmed it ONCE and always adding the same object instead of adding a new one each time. In fact you are adding references to the same object. All references of this object will have the same content.
DonManfred Expert Licensed User Longtime User Jun 27, 2015 #5 Ohh, i forgot: It´s not a BUG, it´s a feature
wizard699 Active Member Licensed User Longtime User Jun 27, 2015 #6 It's true!!!!! I'm stupid. Thanks DonManfred