Wie File of String ?
Hallo,
ich will ein File bestehend aus vielen Strings schreiben und lesen derart :
Delphi-Quellcode:
Ich will einfach nur ein StringArray abspeichern und wieder auslesen - mehr nicht. procedure TForm1.B_EichFilmSpeichernClick(Sender: TObject); var i,j : integer; Setup: array[0..155] of string; SetupFile : file of string; // * dieses mag DELPHI nicht //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ begin for i := 0 to 150 do begin Setup[i]:=''; end; Setup[1]:='28.02.2006'; Setup[2]:='17:14:58'; Setup[3]:= IntToStr(pGrad); for i := 0 to 9 do begin Setup[4+i]:= FloatToStr(pKoef[i]); end; for i := 1 to 26 do begin Setup[20+i]:= FloatToStr(EFilm.Werte[1,i]); Setup[70+i]:= FloatToStr(EPlan.Werte[1,i]); Setup[120+i]:= FloatToStr(Werte[i]); end; AssignFile(SetupFile,SetupVerzeichnis+SetupDatei); Rewrite(SetupFile); for i := 1 to 150 do begin Write(SetupFile,Setup[i]); end; CloseFile(SetupFile); end; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ procedure TForm1.FormCreate(Sender: TObject); var SetupFile : File of String; i,j : integer; Setup : array[0..155] of string; k : integer; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ begin Assign(SetupFile,SetupVerzeichnis+SetupDatei); Reset(SetupFile); for i := 1 to 150 do begin Read(SetupFile,Setup[i]); end; CloseFile(SetupFile); end; SetupFile : file of string geht wohl nicht wegen nicht terminierter String - was wäre also die einfachste Alternative? Vielen Dank E. B. |
Re: Wie File of String ?
Wie wäre es mit TStringlist + SaveToFile/LoadFromFile?
|
Re: Wie File of String ?
file of string gibt es nicht.
versuch es mal mit
Delphi-Quellcode:
hibbert
var datei: textfile
|
Re: Wie File of String ?
Wie Bernhard schon geschrieben hat, nimm eine TStringlist, dann kannst du dir auch das Array sparen und bist nicht festgelegt auf deine feste Anzahl Einträge. Ebenso hast du dann zusätzlich noch die Möglichkeit schnell in dieser Liste zu suchen.
|
Re: Wie File of String ?
Und wenn du Einstellungen in eine Datei schreiben willst gibts auch noch Good-Old-Inifile!
Greetz Boombuler |
Danke
TextFile war gut,
Danke, Danke E. B. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:02 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