With Delphi/FPC you have a few choices:

Fixed length arrays, dynamic length arrays, and variant type arrays

Fixed length arrays cannot be resized and their lower and upper bounds are
immutable. The lower and upper bounds can start at any ordinal position. The
upper bound can ever be less than the upper bound. Also, you may use ordinal
types as the bounds. Examples:

var
  ZeroBased: array[0..9] of Integer;
  OneBased: array[1..10] of Integer;
  Balance: array[-1..1] of Integer;
  Data: array[Byte] of Byte;
  BoolStr: array[Boolean] of string;

Dynamic length arrays are a managed type. That is to say the compiler
generates to code to ensure the memory owned by the array is released when a
procedure exits (if the array is a local). Kind of like the managed string
type. You can use the SetLength() and Length() functions to resize/query
them. You can also set them to nil, meaning an empty array. They cannot be
used in a const block unless you set them to nil (which is kind of useless).
Unlike the managed string type dynamic arrays do not copy on write. Dynamic
arrays always use zero based indexing. Examples:

var
  Names: array of string;
  JaggedInts: array of array of Integer;

Both High and Low functions cna be used with fixed and dynamic arrays.
Example:

for X := Low(JaggedInts) to High(JaggedInts) do
  for Y := Low(JaggedInts[X]) to High(JaggedInts[X]) do
    DoSomething(JaggedInts[X, Y]);

Variant type arrays are variants which reference TVarData having a VType of
varArray. The following functions are used to manage variant arrays:

VarArrayCreate
VarArrayOf
VarArrayDimCount
VarArrayLowBound
VarArrayHighBound
ect
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to