var // Define static arrays wordArray : Array[Word] of Integer; // Static, size=High(Word) multiArray : Array[Byte, 1..5] of char; // Static array, 2 dimensions rangeArray : Array[5..20] of string; // Static array, size = 16 // Define dynamic arrays byteArray : Array of Byte; // Single dimension array DynMultiArray : Array of Array of string; // Multi-dimension array // Worker variables i,j : Integer; begin // Show the sizes and ranges of these arrays Writeln('wordArray length = ',Length(wordArray)); Writeln('wordArray lowest element = ',Low(wordArray)); Writeln('wordArray highest element = ',High(wordArray)); Writeln(''); Writeln('multiArray length = ',Length(multiArray)); Writeln('multiArray lowest element = ',Low(multiArray)); Writeln('multiArray highest element = ',High(multiArray)); Writeln(''); // The full range of a static array are available before assignment, // but the values will be unpredictable Writeln('wordArray Element 7 = ',wordArray[7]); Writeln('wordArray Element 20 = ',wordArray[20]); // Use indexing to furnish an array for i := 5 to 20 do Str(i * 5, rangeArray[i]); // Now use indexing to display 2 of the elements Writeln('rangeArray element 7 = '+rangeArray[7]); Writeln('rangeArray element 20 = '+rangeArray[20]); Writeln(''); // Set the length of the single dimension array SetLength(byteArray, 5); // Show the size and range of this array Writeln('byteArray length = ',Length(byteArray)); Writeln('byteArray lowest element = ',Low(byteArray)); Writeln('byteArray highest element = ',High(byteArray)); Writeln(''); // Furnish this array - remember that dynamic arrays start at 0 for i := 0 to 4 do byteArray[i] := i * 5; // Show selected elements from the array Writeln('byteArray element 2 = ',byteArray[2]); Writeln('byteArray element 4 = ',byteArray[4]); Writeln(''); // Set the length of the 1st dimension of the multi-dim array SetLength(DynMultiArray, 3); // Set the length of the 3 sub-arrays to different sizes SetLength(DynMultiArray[0], 1); SetLength(DynMultiArray[1], 2); SetLength(DynMultiArray[2], 3); // Set and show all elements of this array for i := 0 to High(DynMultiArray) do for j := 0 to High(DynMultiArray[i]) do begin Str(i*j, DynMultiArray[i,j]); Writeln('DynMultiArray[',i,',',j,'] = ',DynMultiArray[i,j]); end; end.