Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 5/Multidimensional arrays

Sent here from Multidimensional arrays.

English · Français · Български · 中文(中国) · 日本語

5D - Multidimensional Arrays (author: Tao Yue, state: unchanged)

You can have arrays in multiple dimensions:

pascal
type
  datatype = array [enum_type1, enum_type2] of datatype;

The comma separates the dimensions, and referring to the array would be done with:

pascal
a [5, 3]

Two-dimensional arrays are useful for programming board games. A tic tac toe board could have these type and variable declarations:

pascal
type
  StatusType = (X, O, Blank);
  BoardType = array[1..3,1..3] of StatusType;
var
  Board : BoardType;

You could initialize the board with:

pascal
for count1 := 1 to 3 do
  for count2 := 1 to 3 do
    Board[count1, count2] := Blank;

You can, of course, use three- or higher-dimensional arrays.


From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 5/Multidimensional arrays", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 7 people, 2007–2022

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
KeesNew page: Multidimensional Arrays You can have arrays in multiple dimensions: <font color="#006699"><strong>type</strong></font> datatype <font color="#000000"><strong>=</strong></font> <font ...
Kees
Kees
Kees
VincentText replace - "delphi>" to "syntaxhighlight>" (minor)
Jwdietrich
Swen (minor)
FTurtle
FTurtle
TrevFixed syntax highlighting (minor)
Kai BurghardtKai Burghardt moved page Multidimensional arrays to Basic Pascal Tutorial/Chapter 5/Multidimensional arrays: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: Pe... (minor)
Kai Burghardtbypass redirects [cf. discussion]
Kai Burghardtbypass language bar/categorization template redirect [cf. discussion] (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.