ex37.pp 596 B

123456789101112131415161718192021222324252627
  1. Program ex37;
  2. { Program to demonstrate the TStringCollection.Compare method }
  3. Uses Objects;
  4. Var C : PStringCollection;
  5. S : String;
  6. I : longint;
  7. begin
  8. Randomize;
  9. C:=New(PStringCollection,Init(120,10));
  10. C^.Duplicates:=True; { Duplicates allowed }
  11. Writeln ('Inserting 100 records at random places.');
  12. For I:=1 to 100 do
  13. begin
  14. Str(Random(100),S);
  15. S:='String with value '+S;
  16. C^.Insert(NewStr(S));
  17. end;
  18. For I:=0 to 98 do
  19. With C^ do
  20. If Compare (At(i),At(I+1))=0 then
  21. Writeln ('Duplicate string found at position ',i);
  22. Dispose(C,Done);
  23. end.