| 1234567891011121314151617181920212223242526272829303132 |
- program t65_array_access;
- { t65 -- array ELEMENT and record FIELD access, which is where the width
- matters. CALC does both at once: `Sheet[FX,FY].CellStatus'.
- The point of this fixture is that an element's WIDTH is not its array's. A
- constant subscript folds (index - lower bound) * element size into the
- address, and the value's width becomes the ELEMENT's - so `v[1] := 11' writes
- two bytes, not the whole ten-byte array. A field selection adds the field's
- offset and takes the field's width and class.
- `v[3] := v[1] + v[2]' reads two elements and writes a third, so a wrong
- scaling, a wrong lower-bound subtraction or a wrong store width all change
- the printed number. .out is 33 then 12. }
- type
- Rec = record
- A : Integer;
- B : Integer;
- end;
- var
- v : array [1..4] of Integer;
- r : Rec;
- begin
- v[1] := 11;
- v[2] := 22;
- v[3] := v[1] + v[2];
- writeln (v[3]);
- r.A := 5;
- r.B := 7;
- writeln (r.A + r.B)
- end.
|