Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Array mit 2 Strings (https://www.delphipraxis.net/62077-array-mit-2-strings.html)

Helmi 30. Jan 2006 18:02


Array mit 2 Strings
 
Hallo,

ich steh gerade auf dem Schlauch.

Ich möcht einen Array, der wie folgt aufgebaut ist:

Delphi-Quellcode:
UpdateListe: array['Monitor_Client.exe', 'Functions.dll'] of String;
also ein Array mit 2 Strings.

Irgendwie bring ich das nicht hin...

dahead 30. Jan 2006 18:18

Re: Array mit 2 Strings
 
Da ich nicht genau weiß ob das Array jetzt nur zwei Elemente enthalten soll, oder pro Element zwei Strings hier die verschiedenen Varianten:

Delphi-Quellcode:
type
  TMySmallArray = Array[0..1] of String;
var
  fMySmallArray: TMySmallArray;
Aufruf wäre so:
Delphi-Quellcode:
  fMySmallArray[0] := 'Test1.exe';
  fMySmallArray[1] := 'Test2.exe';
oder als Record mit den Strings als Feld:

Delphi-Quellcode:
type
  TStringRecord = record
    fFeld1,
    fFeld2: String;
  end;
  TStringRecordArraySmall = Array[0..1] of TStringRecord; // Festgelegte Größe von 0 bis 1
  TStringRecordArrayDyn  = Array of TStringRecord; // Dynamische Größe
var
  fStringRecordArraySmall: TStringRecordArraySmall;
Aufruf wäre so:
Delphi-Quellcode:
  fStringRecordArraySmall[0].fFeld1 := 'Test1.exe';
  fStringRecordArraySmall[0].fFeld2 := 'Test2.exe';

marabu 30. Jan 2006 18:19

Re: Array mit 2 Strings
 
Oder als Konstante:

Delphi-Quellcode:
const
  TwoStrings: array [0..1] of String = ('string1', 'string2');
Grüße vom marabu

Helmi 30. Jan 2006 18:33

Re: Array mit 2 Strings
 
Zitat:

Zitat von marabu
Oder als Konstante:

Delphi-Quellcode:
const
  TwoStrings: array [0..1] of String = ('string1', 'string2');
Grüße vom marabu

*den Kopf auf die Tischkante hau*
Genau das wollte ich machen

merci marabu


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:17 Uhr.

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