Pointers for newbies
Posted on 2003-02-25
I am coming from VB world and there are no pointers like in Pascal, so here is my dilema (although I have read something abot them and have kind of picture what they are).
I use TString to store some information from database. I am using AddObject method and store "Name" as string and TObject(rst.FieldByName('Record_id').AsInteger);
code goes like this
1. I have modal dialog with list box. OnCreate I am calling db:
for i:=0 to rst.RecordCount-1 do
rst.Free;//HERE IS MY QUESTION
Is rst set to nil after calling rst.Free? I found it still in memory after calling Free.
Is that because I added pointers to those strings in DialogBox?
What happens if I explicitly set it to nil? I still can access Pointer(LongInt(MyListBox...)) which means that Record_id is actually added to the list. If it's pointer that points to my dataset's records, and I kill that dataset, what happens with my Objects in StringList?
Is it safe to do things the way I do in the above procedure?