Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Probleme mit record und file (https://www.delphipraxis.net/122535-probleme-mit-record-und-file.html)

kai123 17. Okt 2008 17:53


Probleme mit record und file
 
Hallo!
Ich habe immoment ein Problem mit einem File...Ich wollte eine Schriftfarbe und einen Schriftnamen, die über einen Fontdialog bestimmt werden, in einen File speichern. Dazu habe ich einen record benutzt, der die Typen TFontname und Tcolor zusammenfasst. Als ich eine File mit dem neuen Typ erstellen wollte, zeigt mir delphi folgenden Fehlermeldung beim debuggen an: [Fehler] Grapheinstellungen_Unit3.pas(78 ): E2155 Typ 'Tabc' benötigt Finalization - nicht im Dateityp erlaubt
Mein Quellcode sieht, wie folgt aus:

Delphi-Quellcode:
type Tschrift= Record
n: TFontname;
c: Tcolor;
end;
var f: File of Tschrift;
c,n: Tschrift;
      ...
c:=Fontdialog1.Font.Color;
n:=Fontdialog1.Font.Name;
Assignfile(f, 'C:\Program Files\Feldmühle\Grapheinstellungen.einst');
Rewrite(f);
Write(f,c,n);
Closefile(f);
In "Sonstige Fragen zu Delphi" war schon ein ähnlicher Beitrag vom 28.02.07 "Probleme mit File" (http://www.delphipraxis.net/internal...t.php?t=104594) jedoch war da das Problem, dass die Stringlänge angegeben werden musste. Hier werden aber keine Strings benutzt! Wo liegt das Problem?

Gruß kai

Uwe Raabe 17. Okt 2008 18:05

Re: Probleme mit record und file
 
Zitat:

Zitat von kai123
Hier werden aber keine Strings benutzt!

Doch! TFontName = type string;

hoika 17. Okt 2008 18:26

Re: Probleme mit record und file
 
Hallo,

und als Anhang,

ändere TFontName in ShortString oder String[XX]


Heiko

kai123 17. Okt 2008 19:52

Re: Probleme mit record und file
 
Ich habe jetzt den Typ TFontname auf Shortstring geändert, aber jetzt wird mir angezeigt, dass TFontname und Tschrift inkompatible typen sind. Außerdem sind auch Tcolor und Tschrift inkompatible typen...Das darf doch eig. nicht sein...ich hab doch ein record definiert!?

Klaus01 17. Okt 2008 20:01

Re: Probleme mit record und file
 
Probiere es mal so:

Delphi-Quellcode:
type
  Tschrift= Record
    n: TFontname;
    c: Tcolor;
  end;

var
  f: File of Tschrift;
  Schrift: Tschrift;
      ...
Schrift.c:=Fontdialog1.Font.Color;
Schrift.n:=Fontdialog1.Font.Name;

Assignfile(f, 'C:\Program Files\Feldmühle\Grapheinstellungen.einst');
Rewrite(f);
Write(f,Schrift);
Closefile(f);
.. und vielleicht nochmals die Anwendung von Records studieren.

Grüße
Klaus

kai123 17. Okt 2008 20:11

Re: Probleme mit record und file
 
Vielen Dank für die Hilfe...es funktioniert jetzt... :-D


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