Missing object info within TStringList...
OK...I feel like an idiot, but would someone please explain what I'm
doing wrong here. I need to store objects in a TStringList. I found
that if the object is of type TObject, I would lose access to the
object's information as soon as the function lost focus. Therefore, by
recommendation of another Delphite, I descend from TComponent so the
form takes care of destroying the objects. Maybe somewhere along these
lines I'm going wrong. Here's the code...
type
PhoneTypeInfo = class(TComponent)
Code: String[2];
Description: String[10];
end;
PhoneTypes := TStringList.Create;
PhoneTypestable := PhoneBookDB.OpenRecordset( 'PhoneTypes' );
PhoneTypestable.Index := 'PrimaryKey';
PhoneTypeCount := PhoneTypestable.RecordCount;
PhoneTypestable.MoveFirst;
for i := 1 to PhoneTypeCount do
begin
PhoneTypeRec := PhoneTypeInfo.Create(self);
PhoneTypeRec.Code := PhoneTypestable.Fields['Code'].Value;
PhoneTypeRec.Description :=
PhoneTypestable.Fields['Description'].Value;
//OK right here!
PhoneTypes.AddObject( PhoneTypeRec.Code, PhoneTypeRec );
//Info GONE!
PhoneTypestable.MoveNext;
end;
Right after I AddObject, I can no longer see PhoneTypeRec.Description OR
the value of Description from within the stringlist. What gives???
Thanks for any help in advance,
Bruce Goldstein
Software Engineer
Interactive Strategies, Inc.
br...@centcon.com