Hi everybody,
Working with Lazarus Pascal 2.012 FPC 2.3.0 on Windows and Linux
I'm new to Lazarus for a few months so be cool
I have 3 Units to create a Card Game:
A Form Unit for the main program
A Card Unit to store the Card Parameters (Class TCard).
A Deskcreator Unit to create a desk card (Class TDeskCreator).
Containing :
public
CardsList: specialize TObjectList<Tcard>; // To store the list of Cards
function CreateCards():specialize TObjectList<Tcard>; to create the Desk Card
function TDeskCreator.CreateCards():specialize TObjectList<Tcard>;
var
...
begin
CardsList := specialize TObjectList<Tcard>.Create;
...
CardsList.Add(NewCard);
...
// Here CardList.Count = 52, it's O.K.
// All Cards in the List are valid
exit(CardsList);
// also try Result := CardsList;
end
A Form Unit for the main program (Class TCardMagicForm).
Containing:
private
MyDesk: TDeskCreator;
Cards: specialize TObjectList<Tcard>;
procedure TCardMagicForm.InitDesk();
begin
MyDesk := TDeskCreator.Create;
Cards := MyDesk.CreateCards();
// Here Cards.Count = 0, Not O.K.
end;
My problem:
I don't know how to return my TObjectList from my Deskcreator to my main program...
The Count in the list is always 0 in the main form.
If I remove the Deskcreator Unit and put all except the TCard Unit in the main Form, it is working !!!
Any idea?