| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- program t79_strfield;
- { t79 -- a STRING field written through a DI-addressed record element.
- CALC.INC:162, immediately after the set:
- Contents := '';
- Contents is String[70]. Within `with Sheet[I,J] do' the record's address
- is in DI, so the counted-string copy has to store <len><chars> through it,
- truncated to the field's capacity. Also covers a string VARIABLE source
- (strstore with DI as the destination), a plain record field (symbol+off),
- and the neighbour N to prove the copy stops at the field.
- A short literal must set the length to the SOURCE length, not the capacity:
- storing the capacity would print the bytes that happen to follow the
- literal. }
- type
- Cell = record
- S : string[5];
- N : integer;
- end;
- var
- r : Cell;
- g : array [1..2, 1..3] of Cell;
- i, j : integer;
- t : string[10];
- begin
- with r do
- begin
- S := 'abc';
- N := 4
- end;
- writeln (r.S);
- i := 2;
- j := 3;
- with g[i,j] do
- begin
- S := 'xy';
- N := 9
- end;
- writeln (g[2,3].S);
- t := 'hello';
- with r do
- S := t;
- writeln (r.S);
- with r do
- S := 'abcdefgh';
- writeln (r.S);
- writeln (r.N)
- end.
|