![]() |
const array of record
Wie kann ich einem Array of Record Konstanten zuordnen?
Delphi-Quellcode:
ciao
type
TRec = record Text: string; Zahl: integer; end; const MyArray: array[0..1] of TRec = (('Str1',4),('str2',7)); // wie muss dieser Syntax richtig aussehen? |
Re: const array of record
So muss es gehen ;-)
Delphi-Quellcode:
type
TRec = record Text: string; Zahl: integer; end; const MyArray: array[0..1] of TRec = ((Text: 'Str1'; Zahl: 4), (Text: 'str2'; Zahl: 7)); |
Re: const array of record
Danke Dir :thumb:
|
AW: const array of record
Hallo,
aber was ist, wenn im Record selbst ein Array steht. Wie kann man dieses dann zuordnen?
Delphi-Quellcode:
Das geht leider nicht:
type
TRec = record Text: string; Zahlen: Array [0..1] of Byte; end;
Delphi-Quellcode:
Hier heißt es 'Inkompatible Typen: Array und Set':
const
MyArray: array[0..1] of TRec = ((Text: 'Str1'; Zahlen[0]: 4; Zahlen[1]: 2), (Text: 'Str2'; Zahlen[0]: 9; Zahlen[1]: 3));
Delphi-Quellcode:
Und bei dieser Variante bekomme ich mit D6 immer einen DCC60.dll-Fehler:
const
MyArray: array[0..1] of TRec = ((Text: 'Str1'; Zahlen: [4,2]), (Text: 'Str2'; Zahlen: [9,3]));
Delphi-Quellcode:
const
MyArray: array[0..1] of TRec = ((Text: 'Str1'; Zahlen: 4; Zahlen: 2), (Text: 'Str2'; Zahlen: 9; Zahlen: 3)); |
AW: const array of record
Hallo,
Versuchs mal so:
Delphi-Quellcode:
(aber keine Garantie)
const
MyArray: array[0..1] of TRec = ((Text: 'Str1'; Zahlen: (4,2)), (Text: 'Str2'; Zahlen: (9,3))); |
AW: const array of record
Sieht gut aus, danke! :thumb:
|
AW: const array of record
Hallo, weiß jemand, wie die Konstantendeklaration in diesem Fall aussieht?:
Delphi-Quellcode:
Also ein <array of record> innerhalb eines records.
type
TZahl = record // ist natürlich Unsinn, aber als Beispiel genügt es... Vorkomma: integer; Nachkomma: integer; end; TRec = record Text: string; Zahlen: Array of TZahl; end; Danke schonmal! |
AW: const array of record
Ich weiß jetzt nicht ob ein dyn Array in einer const geht aber die Wertübergabe müßte so aussehen:
Delphi-Quellcode:
ohne Gewehr solche Konstrukte hab ich lang nicht mehr benutzt.
const
myvalue:trec=('meintext',(1,2),(3,4),(5,6)); Gruß K-H |
AW: const array of record
Zitat:
Man kann keine Konstanten für dynamische Arrays anlegen. (leider) |
AW: const array of record
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:43 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 by Thomas Breitkreuz