t79_strfield.pas 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. program t79_strfield;
  2. { t79 -- a STRING field written through a DI-addressed record element.
  3. CALC.INC:162, immediately after the set:
  4. Contents := '';
  5. Contents is String[70]. Within `with Sheet[I,J] do' the record's address
  6. is in DI, so the counted-string copy has to store <len><chars> through it,
  7. truncated to the field's capacity. Also covers a string VARIABLE source
  8. (strstore with DI as the destination), a plain record field (symbol+off),
  9. and the neighbour N to prove the copy stops at the field.
  10. A short literal must set the length to the SOURCE length, not the capacity:
  11. storing the capacity would print the bytes that happen to follow the
  12. literal. }
  13. type
  14. Cell = record
  15. S : string[5];
  16. N : integer;
  17. end;
  18. var
  19. r : Cell;
  20. g : array [1..2, 1..3] of Cell;
  21. i, j : integer;
  22. t : string[10];
  23. begin
  24. with r do
  25. begin
  26. S := 'abc';
  27. N := 4
  28. end;
  29. writeln (r.S);
  30. i := 2;
  31. j := 3;
  32. with g[i,j] do
  33. begin
  34. S := 'xy';
  35. N := 9
  36. end;
  37. writeln (g[2,3].S);
  38. t := 'hello';
  39. with r do
  40. S := t;
  41. writeln (r.S);
  42. with r do
  43. S := 'abcdefgh';
  44. writeln (r.S);
  45. writeln (r.N)
  46. end.