2
0

ex23.pp 505 B

1234567891011121314151617181920212223242526
  1. Program ex23;
  2. { Program to demonstrate the TCollection.At method }
  3. Uses Objects,MyObject; { For TMyObject definition and registration }
  4. Var C : PCollection;
  5. M : PMyObject;
  6. I : Longint;
  7. begin
  8. C:=New(PCollection,Init(100,10));
  9. For I:=1 to 100 do
  10. begin
  11. M:=New(PMyObject,Init);
  12. M^.SetField(100-I);
  13. C^.Insert(M);
  14. end;
  15. For I:=0 to C^.Count-1 do
  16. begin
  17. M:=C^.At(I);
  18. Writeln ('Object ',i,' has field : ',M^.GetField);
  19. end;
  20. C^.FreeAll;
  21. Dispose(C,Done);
  22. end.