unit mBuchliste;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, mBuch, StdCtrls;
type
TfMain =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{}
protected
procedure LineExtract;
public
Buchliste:
Array[1..1602]
of TBuch;
end;
var
fMain: TfMain;
s:
string;
z: integer;
const
MyDat ='
Buecher.txt';
implementation
{$R *.dfm}
function PosEx(
const Substr:
string;
const S:
string; Offset: Integer): Integer;
begin
if Offset <= 0
then Result := 0
else
Result := Pos(Substr, Copy(S, Offset, Length(S)));
if Result <> 0
then
Result := Result + Offset - 1;
end;
procedure TfMain.LineExtract;
var
x,y: integer;
begin
x := 0;
y := 1;
For x := 1
to 7
do
begin
If x <> 7
then
begin
Case x
of
1: Buchliste[z].ID := StrToInt(Copy(s, y, PosEx('
;', s, y) - y));
2: Buchliste[z].Thema := Copy(s, y, PosEx('
;', s, y) - y);
3: Buchliste[z].Autor := Copy(s, y, PosEx('
;', s, y) - y);
4: Buchliste[z].Titel := Copy(s, y, PosEx('
;', s, y) - y);
5: Buchliste[z].Ort := Copy(s, y, PosEx('
;', s, y) - y);
6:
begin
If Copy(s, y, PosEx('
;', s, y) - y) <> '
'
then
Buchliste[z].Erscheinungsjahr := StrToInt(Copy(s, y, PosEx('
;', s, y) - y))
Else if Copy(s, y, PosEx('
;', s, y) - y) = '
'
then
Buchliste[z].Erscheinungsjahr := 0;
end;
end;
y := PosEx('
;', s, y) + 1;
end
Else if x = 7
then
begin
Buchliste[z].Verlag := Copy(s, y, Length(s) - y + 1);
end;
end;
end;
procedure ReadIn;
var
datei: Textfile;
begin
z := 0;
assignfile(datei,MyDat);
reset(datei);
while not EOF(datei)
do
begin
readln(datei,s);
z := z + 1;
fMain.LineExtract;
end;
closefile(datei);
end;
procedure TfMain.FormCreate(Sender: TObject);
begin
ReadIn;
end;
end.