| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- program t75_arrvar;
- { t75 -- variable ARRAY subscripts.
- CALC.INC:130 has `XPos[Count]' - a run-time index into a typed-constant
- array - and later `Sheet[FX,FY]'. A CONSTANT index folds into boff; a
- run-time one is (i - lower) * elemsize from the base, and the element's
- address rides in DI, the same shape string subscripts use. What is new is
- the WIDTH: an array element is one byte or two, not always a character.
- Covers a global Integer array, a global Byte array, a typed-constant array
- indexed by a Char, a LOCAL array, writes whose right-hand side also uses a
- subscript (DI must survive the parse), and reads used in expressions. }
- type
- Letters = array ['A'..'C'] of Integer;
- const
- X : Letters = (10, 20, 30);
- var
- a : array [1..5] of Integer;
- b : array [1..5] of Byte;
- i : Integer;
- c : Char;
- procedure Local;
- var
- v : array [1..3] of Integer;
- k : Integer;
- begin
- for k := 1 to 3 do
- v[k] := k * 5;
- writeln (v[2])
- end;
- begin
- for i := 1 to 5 do
- a[i] := i * 10;
- writeln (a[3]);
- i := 2;
- writeln (a[i]);
- a[i] := 99;
- writeln (a[2]);
- c := 'C';
- writeln (X[c]);
- for i := 1 to 3 do
- b[i] := i;
- writeln (b[2]);
- Local;
- b[2] := 7;
- a[3] := b[2] + 1;
- writeln (a[3])
- end.
|