Registriert seit: 26. Nov 2003
Ort: Berlin
343 Beiträge
Delphi 2006 Professional
|
Re: Several questions
2. Feb 2005, 13:32
I try to answer in english ^^
1.) You must load your file into a stream or Memo Component
Exp.: Memo1.Lines.LoadFromFile('c:\Airplane.txt');
2.) I would create an Record for the current "Flightplan"
Exp.:
Delphi-Quellcode:
type FPlan = record
FAirCraft : String;
FAirPort : String;
FDate : String;
FWeek : String;
end;
3.) You need to fill this record with the current Flightplan. To do this I would seperate the "Line" through the comma ^^
Exp.:
Delphi-Quellcode:
type FPlan = record
FAirCraft : String;
FAirPort : String;
FDate : String;
FWeek : String;
end;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var CurLine : String;
CurComma : Byte;
CurFlight : FPlan;
begin
// load to memo (or stringlist / stream)
Memo1.Lines.LoadFromFile('c:\Airplane.txt');
// get the first line from the txt file (0 = first)
// AC#1,OO-ONJ,99%,WEEK,IFR,6/04:00:00,6/04:39:54,260,F,050,EDEB,6/07:00:00,6/07:39:54,260,F,051,EDEM
if Memo1.Lines.Count > 0 then
CurLine := Memo1.Lines[0];
// now find the next comma
if Length(CurLine) > 0 then
CurComma := Pos(CurLine, ',');
// copy the text until the comma
CurFlight.FAirCraft := Copy(CurLine, 0, CurComma - 1);
// not cut the first entry from the line
CurLine := Copy(CurLine, CurComma, Length(CurLine) - CurComma);
// And now repeat that und you geht the OO-ONJ .. 99% .. WEEK
end;
However, that should be a possibility to combine these files...
///Added:
When you want to export something you would recommend to use 'IniFiles'
Delphi-Quellcode:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IniFiles;
var
CurPlan : FPlan;
implementation
procedure TForm1.Button1Click(Sender: TObject);
var ini :TIniFile;
begin
ini := TIniFile.Create('c:\export.txt');
ini.WriteString('CurFlight', 'Aircraft', CurPlan.FAirCraft;
ini.WriteString('CurFlight', 'AirPort', CurPlan.FAirPort;
//........
ini.Free;
end;
Christian Reber
|
|
Zitat
|