I'm new to delphi and programming in general. I have a problem that when I compile and run the following DLL procedure I get an I/O Error 998. Could you please point out what I'm doing wrong while making the least possible amount of changes to my code? As far as I can tell it has to be a problem with the way I'm handling my files.
The idea of this procedure to to accept data from the VCL application using the DLL, save it to a record and then save the record to a .dat file.
type
plist = ^game;
tdata = record
nazwa: shortstring;
wydawca: shortstring;
rokwyd: shortstring;
gatunek1: shortstring;
gatunek2: shortstring;
end;
game = record
data: tdata;
pointer: plist;
end;
{$R *.res}
procedure DodajElement (var field1, field2, field3, field4, field5 : shortstring); stdcall;
var
BazaDanych : file of game;
first, current: plist;
begin
AssignFile(BazaDanych, 'BazaDanychGier.dat');
if not FileExists('BazaDanychGier.dat') then
begin
new(first);
first^.data.nazwa := field1;
first^.data.wydawca := field2;
first^.data.rokwyd := field3;
first^.data.gatunek1 := field4;
first^.data.gatunek2 := field5;
first^.pointer := nil;
Rewrite(BazaDanych);
Write(BazaDanych, first^);
CloseFile(BazaDanych);
end
else
begin
Reset(BazaDanych);
Read(BazaDanych, first^);
CloseFile(BazaDanych);
current := first;
new(first);
first^.data.nazwa := field1;
first^.data.wydawca := field2;
first^.data.rokwyd := field3;
first^.data.gatunek1 := field4;
first^.data.gatunek2 := field5;
first^.pointer := current;
Rewrite(BazaDanych);
Write(BazaDanych, first^);
CloseFile(BazaDanych);
end;
end;
Sorry for the foreign variable names.