/*
Last example
This example inserts two structures into a list object and displays the contents of the last structure in the list on the form:
*/ 
typedef struct AList
{
  int I;
  char C;
} TAList;
typedef TAList* PAList;

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  PAList AStruct;
  TList *MyList = new TList;
  // fill the TList
  AStruct = new TAList;
  AStruct->I = 100;
  AStruct->C = 'Z';
  MyList->Add(AStruct);
  AStruct = new TAList;
  AStruct->I = 99;
  AStruct->C = 'X';
  MyList->Add(AStruct);
  
// display the contents of the last record
  AStruct = (PAList) MyList->Last();
  Edit1->Text = IntToStr(AStruct->I);
  Edit2->Text = AStruct->C;
 
  // Clean up – must free memory for the items as well as the list
  for (int i = 0; i < MyList->Count; i++)
  {
    AStruct = (PAList) MyList->Items[i];
    delete AStruct;
  }
  delete MyList;
} 
