Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Fester 2 dimensionales array of string (https://www.delphipraxis.net/144258-fester-2-dimensionales-array-string.html)

Jackie1983 3. Dez 2009 14:22


Fester 2 dimensionales array of string
 
Servus,

brauche einen 2 dimensionalen array of string.
So kein Problem
Delphi-Quellcode:
const
  meinarray : array[1..4] of string =
    ('wert1',
     'wert2',
     'wert3',
     'wert4');
Jetzt brauche ich aber für jeden wert noch einen namen.
Wie wird das deklariert?
Hatte schon probiert:
Delphi-Quellcode:
const
  meinarray : array[1..4,1..1] of string =
    (('name','wert1'),
     ('name','wert2'),
     ('name','wert3'),
     ('name','wert4'));
Mfg

Bernhard Geyer 3. Dez 2009 14:26

Re: Fester 2 dimensionales array of string
 
wie wäre es mit 1..2 anstatt 1..1?

und angabe der Fehlermeldung wäre ganz schön.

Jackie1983 3. Dez 2009 14:57

Re: Fester 2 dimensionales array of string
 
ok es war 1..2
jetzt habe ich es, thx

himitsu 3. Dez 2009 15:06

Re: Fester 2 dimensionales array of string
 
alternativ ginge auch noch sowas,
Delphi-Quellcode:
const
  meinarray : array[1..4] of record Name, Wert : string; end = (
    (Name: 'name'; Wert: 'wert1'),
    (Name: 'name'; Wert: 'wert2'),
    (Name: 'name'; Wert: 'wert3'),
    (Name: 'name'; Wert: 'wert4'));
welches im Code eventuell übersichtlicher ist, z.B.
Delphi-Quellcode:
DerZweiteName := meinarray[2].Name;
statt
Delphi-Quellcode:
DerZweiteName := meinarray[2, 1];

Jackie1983 3. Dez 2009 15:22

Re: Fester 2 dimensionales array of string
 
das ist sogar noch besser.... thx


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:30 Uhr.

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