Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Array definition (https://www.delphipraxis.net/81271-array-definition.html)

bundy 24. Nov 2006 11:18

Re: Array definition
 
das würde bedeuten ich müsste das so machen


Delphi-Quellcode:

type
Daystore = array of string
end;

type
  TWorkingtable = class
  Test:Array of DayStore;

  public
  constructor Create ;

  end;

mkinzler 24. Nov 2006 12:05

Re: Array definition
 
Eher so:

Delphi-Quellcode:
type
  Daystore = array of string;

  TWorkingtable = class
       Test:Array of DayStore;

    public
       constructor Create ;

  end;

bundy 24. Nov 2006 13:42

Re: Array definition
 
wieso kann ich dann im
Delphi-Quellcode:
constructor TWorkingtable.Create;
begin
 SetLength(DayStore,2); //<-----   
end;
nicht auf DayStore zugreifen, es steht mir bei setlength nich zu Verfügung.


lg
Bundy

mkinzler 24. Nov 2006 13:52

Re: Array definition
 
Weil der Member Test heißt ;-)

Cöster 24. Nov 2006 13:54

Re: Array definition
 
Mit SetLength nimmt man keine Änderung an einem Typen vor (Typen sind nach der Definition nicht mehr umdefinierbar), sondern an einer Variablen.

bundy 24. Nov 2006 14:59

Re: Array definition
 
ahhhh jetzt hab ich es geschnallt :thumb:

das Sieht dann so aus

Delphi-Quellcode:
type
  MyStore = Array of String;

  TWorkingtable = class
  DayStore : MyStore;
  Test:Array of DayStore;

  public
  constructor Create ;

  end;

implementation





constructor TWorkingtable.Create;
begin
 SetLength(DayStore,2);
end;

Cöster 24. Nov 2006 16:09

Re: Array definition
 
Nenene. Nicht array of <Variablenname> sondern array of <Typbezeichner>

bundy 24. Nov 2006 16:42

Re: Array definition
 
könntest du mir mit einen Code Sample aushelfen :wall:

Cöster 24. Nov 2006 17:21

Re: Array definition
 
Delphi-Quellcode:
type
  TIntArray = array of Integer;

  TMyClass = class
  private
    procedure SetSpaltenAnzahl(Anz: Integer);
    FTestArray: array of TIntArray; // 2D-Array. Entspricht array of array of Integer
    FSpaltenAnzahl: Integer;
    FZeilenAnzahl: Integer;
  public
    constructor Create;
    property SpaltenAnzahl: Integer read FSpaltenAnzahl write SetSpaltenAnzahl;
  end;

implementation

constructor TMyClass.Create;
begin
  inherited Create;
  FSpaltenAnzahl := 5;
  FZeilenAnzahl := 2;
  SetLength(FTestArray, 5, 2);
end;

procedure TMyClass.SetSpaltenAnzahl(Anz: Integer);
begin
  FSpaltenAnzahl := Anz;
  SetLength(FTestArray, Anz, FZeilenAnzahl);
end;

bundy 24. Nov 2006 17:23

Re: Array definition
 
danke dir :thumb:


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:10 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz