Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Recordtyp initialisieren? (https://www.delphipraxis.net/28348-recordtyp-initialisieren.html)

Pseudemys Nelsoni 23. Aug 2004 15:12


Recordtyp initialisieren?
 
hoi,

wie kann ich einen recordtyp initialisieren?

theoretisch dachte ich mir das so:

Delphi-Quellcode:
type tmyrec = record
  teststring: string = 'hi';
end;
nun sollte jede variable diesen records den wert "hi" bereits haben. Wie geht das?

maximov 23. Aug 2004 15:19

Re: Recordtyp initialisieren?
 
Das geht leider nicht! bei globalen variablen kannst du aber einzelnd initialisieren:

Delphi-Quellcode:
type tmyrec = record
  teststring: string;
  end;

var
  y:tmyrec = (teststring:'hi');
[delphi]

viel mehr geht nicht :?

Nikolas 23. Aug 2004 15:24

Re: Recordtyp initialisieren?
 
Du könntest dir vielleicht ne KLasse schreiben und dann im Constructor machen was du willst.


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:44 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