YousefEisa
asked on
delphi dll problems !
Dear Experts,
I have a problem with a Delphi written DLL. At initialization, the DLL starts by opening a file of records. Within a loop, it should read each record and put its values into an array. It reads the first record without a problem. When it goes round the loop to read the next record, it gets the wrong values from the record.
When the program runs as a normal Delphi program the problem does not occur. However, when the same program is written as a DLL, the problem occurs.
Are there special rules for DLLs about reading files?
Here is the code where the problem occurs.
try
AssignFile(FHash, DefaultHashFile);
Reset(FHash);
While not eof(FHash) do
begin
Read(FHash,ECell);
//Convert Ecell WideChar array to a unicode string /
CharCount:= 1; S:= '';
repeat
S:= S+ ECell.Str[CharCount];
Inc(CharCount);
until (ECell.Str[CharCount] =#0 ) or (CharCount >= 30);
N:= Ecell.Location;
NameIndex[N].Str:= S;
CharCount:= 1; S:= '';
repeat
S:= S+ ECell.Phono[CharCount];
Inc(CharCount);
until (ECell.Phono[CharCount] =#0 ) or (CharCount >= 30);
NameIndex[N].Phono:= S;
NameIndex[N].DiskStart:= ECell.ArrayStart;
NameIndex[N].DiskDivider:= ECell.ArrayMiddle;
NameIndex[N].DiskTail:= ECell.ArrayEnd;
NameIndex[N].Eastern:= ECell.Eastern;
NameIndex[N].AltMarked:= -1;
end;
Closefile(FHash);
except
DisplayMessage('error reading Main Index table contents');
Closefile(FHash);
Exit;
end;
I have a problem with a Delphi written DLL. At initialization, the DLL starts by opening a file of records. Within a loop, it should read each record and put its values into an array. It reads the first record without a problem. When it goes round the loop to read the next record, it gets the wrong values from the record.
When the program runs as a normal Delphi program the problem does not occur. However, when the same program is written as a DLL, the problem occurs.
Are there special rules for DLLs about reading files?
Here is the code where the problem occurs.
try
AssignFile(FHash, DefaultHashFile);
Reset(FHash);
While not eof(FHash) do
begin
Read(FHash,ECell);
//Convert Ecell WideChar array to a unicode string /
CharCount:= 1; S:= '';
repeat
S:= S+ ECell.Str[CharCount];
Inc(CharCount);
until (ECell.Str[CharCount] =#0 ) or (CharCount >= 30);
N:= Ecell.Location;
NameIndex[N].Str:= S;
CharCount:= 1; S:= '';
repeat
S:= S+ ECell.Phono[CharCount];
Inc(CharCount);
until (ECell.Phono[CharCount] =#0 ) or (CharCount >= 30);
NameIndex[N].Phono:= S;
NameIndex[N].DiskStart:= ECell.ArrayStart;
NameIndex[N].DiskDivider:=
NameIndex[N].DiskTail:= ECell.ArrayEnd;
NameIndex[N].Eastern:= ECell.Eastern;
NameIndex[N].AltMarked:= -1;
end;
Closefile(FHash);
except
DisplayMessage('error reading Main Index table contents');
Closefile(FHash);
Exit;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.