tw0877.pp 385 B

1234567891011121314151617181920212223242526
  1. {$mode objfpc}
  2. program testlist;
  3. uses
  4. Sysutils,
  5. Classes;
  6. var
  7. l: TList;
  8. IsCaught: boolean;
  9. begin
  10. L:= TList.Create;
  11. IsCaught:=false;
  12. Try
  13. WriteLn(LongInt(L[0]));{L[0] not exist, ==> access violation}
  14. L.Free;
  15. Except
  16. on eListError do
  17. IsCaught:=true;
  18. end;
  19. If not IsCaught then
  20. begin
  21. Writeln('Error in TList');
  22. Halt(1);
  23. end;
  24. end.