Dynamic Arrays
Declare a dynamic array without providing the bounds that are necessary for a static array declaration then use the SetLength procedure to set its size. A dynamic array is always zero-based. A simple example follows. The Conversion and ArrayToFile procedures in the demonstrations at the end of this tutorial illustrate more realistic uses.
program DynamicArrayDemo; var NumOfValues : integer; CircleAreas : array of real; i : integer; begin writeln('This program will store temporarily the values of the area' + 'of circles having integer values for the radius then display them.'); write('How many values? '); Readln(NumOfValues); SetLength(CircleAreas, NumOfValues); for i := 0 to NumOfValues - 1 do CircleAreas[i] := pi * i * i; for i := 0 to NumOfValues - 1 do writeln('A circle of radius ',i , ' cm has area ', CircleAreas[i] : 18 : 6, ' sq cm.'); readln; end.