Re: Can't understand why these exceptions occur...
- From: Ikke <ikke@xxxxxxx>
- Date: Sat, 31 May 2008 19:56:55 GMT
Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@xxxxxxxxxxx> wrote in
news:sHh0k.153$%54.143@xxxxxxxxxxxx:
<snip>
Please Disable the io trap {$I-}
Ok, I've added {$I-} to the top of my program.
and use the IOResult after each Read/write
function... to test...
I've made the following changes as well:
--- load cache ---
procedure LoadCache(Const cacheName : String);
var
cache : File of TBufferInfo;
begin
try
if FileExists(cacheName) then
begin
AssignFile(cache, cacheName);
if IOResult <> 0 then WriteLn(IOResult);
Reset(cache);
if IOResult <> 0 then WriteLn(IOResult);
idx := 1;
while Not(eof(cache)) and (idx < Length(files)) do
begin
Read(cache, files[idx]);
if IOResult <> 0 then WriteLn(IOResult);
Inc(idx);
end;
CloseFile(cache);
if IOResult <> 0 then WriteLn(IOResult);
end;
except on e : Exception do
WriteLn('Exception occured: ' + e.Message);
end;
Exit;
end;
--- save cache ---
procedure SaveCache(Const cacheName : String);
var
cache : File of TBufferInfo;
begin
try
AssignFile(cache, cacheName);
if IOResult <> 0 then WriteLn(IOResult);
ReWrite(cache);
if IOResult <> 0 then WriteLn(IOResult);
idx := 1;
while (idx < Length(files)) do
begin
if (files[idx].name <> '') then
begin
Write(cache, files[idx]);
if IOResult <> 0 then WriteLn(IOResult);
end;
Inc(idx);
end;
CloseFile(cache);
if IOResult <> 0 then WriteLn(IOResult);
except on e : Exception do
WriteLn('Exception occured: ' + e.Message);
end;
end;
--- main ---
if IOResult <> 0 then WriteLn('before load ' + IntToStr(IOResult));
LoadCache('FileLocatorBuffer.dat');
if IOResult <> 0 then WriteLn('after load ' + IntToStr(IOResult));
if LowerCase(ParamStr(1)) = 'buffer' then
begin
if IOResult <> 0 then WriteLn('before buffer ' + IntToStr(IOResult));
StartBufferingFiles(ParamStr(2));
if IOResult <> 0 then WriteLn('after buffer ' + IntToStr(IOResult));
end;
if IOResult <> 0 then WriteLn('before save ' + IntToStr(IOResult));
SaveCache('FileLocatorBuffer.dat');
if IOResult <> 0 then WriteLn('after save ' + IntToStr(IOResult));
---
So whenever IOResult is not 0, it should be written inside the console
screen. This never happens, even though exceptions are still thrown. I've
now noticed the exception I/O error 103. A quick Google led me to the
following page
(http://www.faqts.com/knowledge_base/view.phtml/aid/24059/fid/175) where
it is said that:
"A file is assigned and then closed, but the file pointer has not
(for all possible cases) been reset or rewritten, in between."
Which is not the case here. Later on I read:
"This can also be raised if you are trying to write out to a path that
does not exist."
Still not the case.
also...
If IoResult is not 0 , forwarding Pascal IO
functions will fail!
I'm afraid I don't really understand what you're saying here.
I use InOUtRes := 0 when I know the error has
been handled if I don't want to use the IoResult
using the IoResult clears the error after it returns
the current error value.
the InOutRes is the variable that holds it.
On entry, you should always do
InOutRes := 0;
to make sure you don't have any errors from some where else
lingering.
If I add InOutRes := 0 in any of the procedures, I get an error stating
that InOutRes is not a variable.
Thanks,
Ikke
.
- Follow-Ups:
- References:
- Can't understand why these exceptions occur...
- From: Ikke
- Re: Can't understand why these exceptions occur...
- From: Skybuck Flying
- Re: Can't understand why these exceptions occur...
- From: Jamie
- Re: Can't understand why these exceptions occur...
- From: Ikke
- Re: Can't understand why these exceptions occur...
- From: Jamie
- Re: Can't understand why these exceptions occur...
- From: Ikke
- Re: Can't understand why these exceptions occur...
- From: Jamie
- Can't understand why these exceptions occur...
- Prev by Date: Re: Can't understand why these exceptions occur...
- Next by Date: Re: Can't understand why these exceptions occur...
- Previous by thread: Re: Can't understand why these exceptions occur...
- Next by thread: Re: Can't understand why these exceptions occur...
- Index(es):
Relevant Pages
|