Autor Beitrag
Arne
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Mi 24.03.10 12:51 
Moin,

ich habe folgenden Typ in Delphi 2007 deklariert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  TLeistungssteller = record
    mPowerSupplySystemKind  : Byte;
    mCurrentMax             : Byte;
    mVoltage                : Word;
    mCombis                 : array[0..3of Byte;
  end;


Nun möchte ich ein array of TLeistungssteller mit Werten vorbelegen.
In der Art hier:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
const kLeistungssteller : array[0..1of TLeistungssteller = (
  (016220, [1234] ),
  (020220, [4679] )
);

Nur ist obiges syntaktisch nicht korrekt. Kann mir jemand bitte zeigen, wie die Syntax richtig aussehen muß?
Die Delphi-Hilfe ist hier leider keine Hilfe.

Thanx, Arne
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8535
Erhaltene Danke: 473

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 24.03.10 12:55 
Ich hab hier grad kein Delphi, aber das müsste doch so gehen, oder?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
const kLeistungssteller : array[0..1of TLeistungssteller = (
  (016220(1234) ),
  (020220(4679) )
);

_________________
We are, we were and will not be.
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Mi 24.03.10 12:55 
Aus einem Projekt :
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
Type
  TFachKategorie = (fkNaturwissenschaft, fkSport, fkGesellschaft, fkSprache);

  TFach          = Record
    Titel        : String;
    Kategorie    : TFachKategorie;
  end;

Const
  cFaecher : Array[0..17of TFach =
  (
    (Titel     : 'Mathe';
     Kategorie : fkNaturwissenschaft),
    (Titel     : 'Deutsch';
     Kategorie : fkGesellschaft),
    (Titel     : 'Biologie';
     Kategorie : fkNaturwissenschaft),
    (Titel     : 'Chemie';
     Kategorie : fkNaturwissenschaft),
    (Titel     : 'Englisch';
     Kategorie : fkSprache),
    (Titel     : 'Französisch';
     Kategorie : fkSprache),
    (Titel     : 'Geografie';
     Kategorie : fkGesellschaft),
    (Titel     : 'Geschichte';
     Kategorie : fkGesellschaft),
    (Titel     : 'Kunst';
     Kategorie : fkGesellschaft),
    (Titel     : 'Physik';
     Kategorie : fkNaturwissenschaft),
    (Titel     : 'Wirtschaft/Recht';
     Kategorie : fkGesellschaft),
    (Titel     : 'Informatik';
     Kategorie : fkNaturwissenschaft),
    (Titel     : 'Russisch';
     Kategorie : fkSprache),
    (Titel     : 'Sozialkunde';
     Kategorie : fkGesellschaft),
    (Titel     : 'Musik';
     Kategorie : fkGesellschaft),
    (Titel     : 'Ethik';
     Kategorie : fkGesellschaft),
    (Titel     : 'Religion';
     Kategorie : fkGesellschaft),
    (Titel     : 'Sport';
     Kategorie : fkGesellschaft)


  );
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10181
Erhaltene Danke: 1254

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 24.03.10 12:57 
Moin!

So geht das mit einem record, die Array-Version darfst du dann selbst rausfinden: ;)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
const
  Leistungssteller: TLeistungssteller = (
    mPowerSupplySystemKind: 0;
    mCurrentMax: 1;
    mVoltage: 2;
    mCombis: (0,1,2,3)
    );
cu
Narses

//EDIT: Man, bin ich langsam... :(

_________________
There are 10 types of people - those who understand binary and those who don´t.
Arne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Mi 24.03.10 13:03 
Danke!

Lösung:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
const kLeistungssteller : array[0..1of TLeistungssteller = (
  (mPowerSupplySystemKind  : 0;
   mCurrentMax             : 16;
   mVoltage                : 220;
   mCombis                 : (1234)),

  (mPowerSupplySystemKind  : 0;
   mCurrentMax             : 20;
   mVoltage                : 220;
   mCombis                 : (4679))
);


Doppelpunkt als Zuweisungsoperator... Da muss man erstmal drauf kommen. Wäre neben ':=' und '=' die dritte Möglichkeit der Zuweisung.

Thanx, Arne