Board index » delphi » Delphi 1.0 bug. I mean it.

Delphi 1.0 bug. I mean it.

Quote
l...@ozramp.ozramp.net.au (Luke Webber) wrote:
>I posted an article yesterday about an EInOutError. "File access denied"
>exception on my first call to Rewrite. Turns out it was happening because
>I had some code in my form load event which was meant to create some
>directories if they didn't already exist.
>I've worked up a little sample, and I'm pretty {*word*76}y sure that this is
>an authentic bug. I'm not one to cry wolf, but it seems to me that an I/O
>error with {$I-} in effect will cause the next rewrite or reset to fail,
>UNLESS the IOResult function has been called in between. In my case, I
>didn't care if an error occurred, so I hadn't called IOResult.

Don't think it's a bug. The definition of IOResut in the Borland
Pascal 7 and the Delphi 1 help file says:

"If an I/O error occurs and I/O-checking is off, all
subsequent I/O operations are ignored until a call is made to
IOResult. A call to IOResult clears the internal error flag."

Ok, so they aren't being ignored, they are getting an exception, but
either way, you need to call IOResult. Or better still, use
exceptions, since IOResult is declining.

----------------------------------------
Aandi Inston  qu...@dial.pipex.com
Visit http://ds.dial.pipex.com/quite for info on PostScript,
PSAlter, psalters, tea, and small {*word*141} animals. And stuff.  

 

Re:Delphi 1.0 bug. I mean it.


On 23 May 1996 01:13:29 +1000, l...@ozramp.ozramp.net.au (Luke Webber)
wrote:

Quote
>I've worked up a little sample, and I'm pretty {*word*76}y sure that this is
>an authentic bug. I'm not one to cry wolf, but it seems to me that an I/O
>error with {$I-} in effect will cause the next rewrite or reset to fail,
>UNLESS the IOResult function has been called in between. In my case, I
>didn't care if an error occurred, so I hadn't called IOResult.

This isn't a bug, it's behaviour as documented.  Quoting the Object
Pascal Language Guide, p. 140:

"You must call the IOResult function to clear whatever error may have
occurred, even if you aren't interested in the error.  If you don't
and {$I+} is the current state, the next I/O function call fails with
the lingering IOResult error."

If you don't have the Language Guide, you can download it from
www.borland.com.  It's included with all versions of D2, and should
have been with D1, but wasn't even printed at the time D1 was
released.

Duncan Murdoch

Re:Delphi 1.0 bug. I mean it.


I posted an article yesterday about an EInOutError. "File access denied"
exception on my first call to Rewrite. Turns out it was happening because
I had some code in my form load event which was meant to create some
directories if they didn't already exist.

I've worked up a little sample, and I'm pretty {*word*76}y sure that this is
an authentic bug. I'm not one to cry wolf, but it seems to me that an I/O
error with {$I-} in effect will cause the next rewrite or reset to fail,
UNLESS the IOResult function has been called in between. In my case, I
didn't care if an error occurred, so I hadn't called IOResult.

See the sample code below...

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  MyFile : TextFile;
  IOR : integer;
begin
  {$I-}
  MkDir('c:\windows');
  {$I+}
  if MessageDlg('Want to see an exception?', mtConfirmation,
                  [mbYes, mbNo], 0) = mrNo then
    IOR := IOResult;
  AssignFile(MyFile, 'c:\autoexec.bat');
  Reset(MyFile);
end;

____

Looks like a bug to me, and it killed about six hours of my time all up,
so I just wanted to make it known.

Regards
Luke
--
Luke Webber

* Note: The opinions expressed by Luke Webber are in no way supported *
*       by his employers, Luke Webber Consulting Services             *

Re:Delphi 1.0 bug. I mean it.


Quote
l...@ozramp.ozramp.net.au (Luke Webber) wrote:
>I've worked up a little sample, and I'm pretty {*word*76}y sure that this is
>an authentic bug. I'm not one to cry wolf, but it seems to me that an I/O
>error with {$I-} in effect will cause the next rewrite or reset to fail,
>UNLESS the IOResult function has been called in between. In my case, I
>didn't care if an error occurred, so I hadn't called IOResult.

Luke -
     Sounds like documented behaviour to me.  But, I've been using
Borland stuff since Turbo 1.0a, and have read a lot of manuals.  I'm not
sure if it's find-able in the Delphi docs, given their present state.
     Calls to file I/O code will fail if IOResult was allowed to be set
in a {$I-}{$I+} block, and not subsequently cleared by evaluating
IOResult.  ALL calls.  (Not just rewrite/reset.)  This is because the
compiler doesn't have enough AI built in to determine what your next
file I/O operation might be, and if it relies upon the sucessful
completion of the "I/O checking off" operations.
     - Dan

l...@ozramp.ozramp.net.au (Luke Webber) also wrote in the same post:

Quote
>See the sample code below...
>procedure TForm1.BitBtn1Click(Sender: TObject);
>var
>  MyFile : TextFile;
>  IOR : integer;
>begin
>  {$I-}
>  MkDir('c:\windows');
>  {$I+}
>  if MessageDlg('Want to see an exception?', mtConfirmation,
>                  [mbYes, mbNo], 0) = mrNo then
>    IOR := IOResult;
>  AssignFile(MyFile, 'c:\autoexec.bat');
>  Reset(MyFile);
>end;
>____
>Looks like a bug to me, and it killed about six hours of my time all up,
>so I just wanted to make it known.

     - Dan Haygood   (dhayg...@getnet.com)
       Phoenix, Arizona

___________________________
Copyright 1995, Dan Haygood

Other Threads