Pascal samples. Dynamic array types.


Example 1

type
  TArrInt = array of Integer;

procedure TestDynArrayProc(A: array of Integer);
begin
  writeln(Length(A));
  writeln(A[3]);
end;

function RetDynArray: TArrInt;
begin
  SetLength(result, 7);
  result[5] := 2;
end;

var
  A: array of Integer;
  B: array of Integer;
begin
  SetLength(A, 10);
  A[3] := 3;

  TestDynArrayProc(A);

  A := RetDynArray();
  writeln(Length(A));
  writeln(A[5]);

  B := A;

  writeln(B[5]);
end.

Example 2

uses
  SysUtils;
var
  S: String;
begin
  S := Format('abc %s pqr', ['xyz']);
  writeln(S);
end.


Copyright © 2006-2017 Alexander Baranovsky. All rights reserved.