Autor Beitrag
Der Jan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win2k prof, WinXP prof, Linux
D6 Prof, BCB4 Std, BCB6 Ent, BDS 2006 Ent
BeitragVerfasst: Fr 21.10.05 11:10 
Hallo miteinander.

Ich habe ein Array aus Records.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
TodaName = record
    Display: string;
    Real: string;
end;

TodaTypeNames = array[0..6] of TodaName;

var odaNames: TodaTypeNames;


Nun möchte ich dieses Array füllen, aber nicht "Stück für "stück", sondern mit einer Anweisung, etwa so in der Art:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
odaNames := ((Display: 'Bestellung', 'BESTELL'),
  (Display: 'Auftrag', Real: 'AUFTRAG'),
  (Display: 'Lieferschein', Real: 'L-SCHEIN'),
  (Display: 'Korrespondenz', Real: 'KORRESP.'),
  (Display: 'Erinnerung', Real: 'ERINNRG'),
  (Display: 'Mahnung', Real: 'MAHNUNG'),
  (Display: 'Wareneingangsmeldung', Real: 'WE-MELDG'));


Nur, egal, wie ich es ändere, der Compiler findet immer was zu meckern. Bei der o.g. Varainte bemängelt er z.B.
die nicht übereinstimmende Anzahl von Feldern mit der Variablendeklaration.
Ich bin mir aber ziemlich sicher, das dies möglich ist... Nur wie??
flieger-michl
Hält's aus hier
Beiträge: 14

W2K, Linux
D5, FPC
BeitragVerfasst: Fr 21.10.05 11:18 
Titel: Array aus Records füllen
Hallo,

so geht's :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
type
 TodaName = record  
     Display: string;  
     Real: string;  
 end;  

const 
 TodaTypeNames : array[0..6] of TodaName = (
  (Display : 'Disp0'; Real : 'was weiss ich'),
  (Display : 'Disp1'; Real : 'was weiss ich'),
  (Display : 'Disp2'; Real : 'was weiss ich'),
  (Display : 'Disp3'; Real : 'was weiss ich'),
  (Display : 'Disp4'; Real : 'was weiss ich'),
  (Display : 'Disp5'; Real : 'was weiss ich'),
  (Display : 'Disp6'; Real : 'was weiss ich')
 );


Gruß
Michl

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt und Doppelpost gelöscht.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 21.10.05 11:19 
Den Bezeichner "Real" würde ich erstmal ändern. Ist ein reserviertes Wort in Delphi.
iirc musst bei deiner Zuweisung lediglich die Begriffe "Display:" und "Real:" weglassen. Bin imr aber nicht 100%ig sicher.
BattleFrog
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 53

WIN 2000
Delphi 7 Ent.
BeitragVerfasst: Fr 21.10.05 11:27 
Das geht nur bei der Definition der Variable, nicht jedoch danach.
Die Syntax wäre wie folgt:

ausblenden Delphi-Quelltext
1:
var/const variable: RecordTyp = ((Feldname: Wert; Feldname: Wert; ...), ...);					


@jasocul:
Real ist kein reserviertes Wort, sondern nur ein Datentyp.
Und Namen von Typen kann man benutzten.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 21.10.05 11:46 
@BattleFrog:
Das sind Feinheiten :wink: in der Wortwahl. Aber du hast natürlich Recht. Trotzdem würde ich sowas vermeiden.
Der Jan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win2k prof, WinXP prof, Linux
D6 Prof, BCB4 Std, BCB6 Ent, BDS 2006 Ent
BeitragVerfasst: Fr 21.10.05 12:23 
Danke, geht wunderbar