Thema: Delphi Dynamisches Array

Einzelnen Beitrag anzeigen

Benutzerbild von rapante
rapante

Registriert seit: 3. Jun 2009
Ort: OPR
171 Beiträge
 
Delphi XE2 Professional
 
#36

AW: Dynamisches Array

  Alt 2. Sep 2010, 19:23
versuchs mal so, dann ersparst du dir auch die globale Variable...
Delphi-Quellcode:
unit test;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TMyArray = array[0..3] of integer;

  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure fill_array(var ta: TMyArray; wert:integer);
var i:integer;
begin
for i:=low(ta) to high(ta) do
ta[i]:=wert;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  i:integer;
  MyArray: TMyArray;
begin
fill_array( myArray,2);
for i:=low(myarray) to high(myarray) do
Form1.Memo1.Text:=Form1.Memo1.Text+ ' ' +(inttostr(myArray[i]));
end;

end.
  Mit Zitat antworten Zitat