tdynarrec.pp 705 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Program tdynarrec;
  2. {$mode objfpc}
  3. uses
  4. jdk15;
  5. type
  6. tdynrec = record
  7. s: string[10];
  8. end;
  9. procedure error(l: longint);
  10. begin
  11. JLSystem.fout.print('error: ');
  12. JLSystem.fout.println(l);
  13. raise jlexception.create('fatal');
  14. end;
  15. var
  16. r1,r2: array of tdynrec;
  17. rr: tdynrec;
  18. begin
  19. setlength(r1,5);
  20. r2:=r1;
  21. rr.s:='abc';
  22. r1[0]:=rr;
  23. if r2[0].s<>'abc' then
  24. error(0);
  25. rr.s:='def';
  26. if r1[0].s<>'abc' then
  27. error(1);
  28. r1[1]:=rr;
  29. if r1[0].s<>'abc' then
  30. error(2);
  31. setlength(r2,6);
  32. if r1[0].s<>'abc' then
  33. error(3);
  34. if r2[0].s<>'abc' then
  35. error(4);
  36. if r2[1].s<>'def' then
  37. error(3);
  38. rr.s:='ghi';
  39. r1[0]:=rr;
  40. if r2[0].s<>'abc' then
  41. error(5);
  42. end.