Board index » delphi » Error in BP7 Int24 handler?

Error in BP7 Int24 handler?

After RT error 150 (Disk is write protected) during Erase non-empty file,
BlockWrite or Close after write, the program gets the same error (RT150) once
more (either for next I/O operation, or later). Can you tell me if it is my
error, BP error or operating system error?

Similar problem in both real and protected mode, and in TurboVision programs too
(but the error number may be 19 instead of 150).

This problem occured on every hardware I have tried (486, P133, P200MMX, Celeron
266, P II 350).
Problem occured under MSDOS 6.20, 6.22, PCDOS 6.3 and Windows 95/98 when booted
in dos-only mode; did not occur under Windows NT 4.0 nor on Windows 95/98 when
booted GUI.

There may be a problem in the standard Pascal's INT24 handler (maybe the DOS 54H
function call isn't enough to "get DOS into a stable state"?) or in other part
of the RTL. There may be a correction in BP 7.01 but I only have BP 7.0  - could
you try it?

Source enclosed. Steps to demonstrate the problem:
  1. Assure that the program will be able to create, write and delete
     a temporary file c:\$$$.$$$ (or change the TempFName constant).
  2. Compile the program (for real mode).
  3. Prepare a diskette with a non-empty file 'TRY.TRY' in root directory.
     Notice that the file MUST not be empty - otherwise the problem does
     not occur, at least at me.
  4. Boot clean DOS (press F5 to bypass CONFIG.SYS and AUTOEXEC.BAT).
     (You can experiment with different configurations too;
      if you run Windows 95/98, try when restarted in DOS-only mode.)
  5. Write-protect the diskette and insert it into drive a:
  6. Run the program.
     You get this output:
     erase a:\... error 150;
     if you get some additional error 150 message (I get it regularly),
     the problem occured.

I would appreciate any message (tell me your compiler version, OS, and if the
problem occured).

{ **************************************************************** }
program Try;

{ Program to demonstrate Borland Pascal 7.00/MSDOS error (?):
  after error 150 (disk is write protected), some next operation fails
  with error 150 again. }

{$i-}
const
  TryFName = 'a:\TRY.TRY';  { name of existing non-empty file on write-protected
disk }
  TempFName = 'c:\$$$.$$$'; { name for temporary file that program can create }

var
  f: file;
  er: Integer;
  i: Integer;
begin
  { try to write to write-protected disk }
  assign (f, TryFName);
  erase (f); er := IOResult;
  writeln ('Erase ',TryFName,': error ',er);

  { perform some operations on TempFName and report errors if any }
  assign (f, TempFName);
  for i := 1 to 100 do begin
    rewrite (f,1); er := IOResult;
    if (er <> 0) then writeln ('Run ',i,': Rewrite error ',er);
    BlockWrite (f, i,sizeof(i)); er := IOResult;
    if (er <> 0) then writeln ('Run ',i,': BlockWrite error ',er);
    close (f); er := IOResult;
    if (er <> 0) then writeln ('Run ',i,': Close error ',er);
    erase (f); er := IOResult;
    if (er <> 0) then writeln ('Run ',i,': Erase error ',er);
  end;
end.

 

Re:Error in BP7 Int24 handler?


try resetting IOResult in the second part

IOResult:=0;

Quote
Jiri Cerny <ce...@NOSPAMchaps.cz> wrote in message

news:7a17qq$u23$1@argo.telecom.cz...
Quote
>After RT error 150 (Disk is write protected) during Erase non-empty file,
>BlockWrite or Close after write, the program gets the same error (RT150)
once
>more (either for next I/O operation, or later). Can you tell me if it is my
>error, BP error or operating system error?

>Similar problem in both real and protected mode, and in TurboVision
programs too
>(but the error number may be 19 instead of 150).

>This problem occured on every hardware I have tried (486, P133, P200MMX,
Celeron
>266, P II 350).
>Problem occured under MSDOS 6.20, 6.22, PCDOS 6.3 and Windows 95/98 when
booted
>in dos-only mode; did not occur under Windows NT 4.0 nor on Windows 95/98
when
>booted GUI.

>There may be a problem in the standard Pascal's INT24 handler (maybe the
DOS 54H
>function call isn't enough to "get DOS into a stable state"?) or in other
part
>of the RTL. There may be a correction in BP 7.01 but I only have BP 7.0  -
could
>you try it?

>Source enclosed. Steps to demonstrate the problem:
>  1. Assure that the program will be able to create, write and delete
>     a temporary file c:\$$$.$$$ (or change the TempFName constant).
>  2. Compile the program (for real mode).
>  3. Prepare a diskette with a non-empty file 'TRY.TRY' in root directory.
>     Notice that the file MUST not be empty - otherwise the problem does
>     not occur, at least at me.
>  4. Boot clean DOS (press F5 to bypass CONFIG.SYS and AUTOEXEC.BAT).
>     (You can experiment with different configurations too;
>      if you run Windows 95/98, try when restarted in DOS-only mode.)
>  5. Write-protect the diskette and insert it into drive a:
>  6. Run the program.
>     You get this output:
>     erase a:\... error 150;
>     if you get some additional error 150 message (I get it regularly),
>     the problem occured.

>I would appreciate any message (tell me your compiler version, OS, and if
the
>problem occured).

>{ **************************************************************** }
>program Try;

>{ Program to demonstrate Borland Pascal 7.00/MSDOS error (?):
>  after error 150 (disk is write protected), some next operation fails
>  with error 150 again. }

>{$i-}
>const
>  TryFName = 'a:\TRY.TRY';  { name of existing non-empty file on
write-protected
>disk }
>  TempFName = 'c:\$$$.$$$'; { name for temporary file that program can
create }

>var
>  f: file;
>  er: Integer;
>  i: Integer;
>begin
>  { try to write to write-protected disk }
>  assign (f, TryFName);
>  erase (f); er := IOResult;
>  writeln ('Erase ',TryFName,': error ',er);

>  { perform some operations on TempFName and report errors if any }
>  assign (f, TempFName);
>  for i := 1 to 100 do begin
>    rewrite (f,1); er := IOResult;
>    if (er <> 0) then writeln ('Run ',i,': Rewrite error ',er);
>    BlockWrite (f, i,sizeof(i)); er := IOResult;
>    if (er <> 0) then writeln ('Run ',i,': BlockWrite error ',er);
>    close (f); er := IOResult;
>    if (er <> 0) then writeln ('Run ',i,': Close error ',er);
>    erase (f); er := IOResult;
>    if (er <> 0) then writeln ('Run ',i,': Erase error ',er);
>  end;
>end.

Re:Error in BP7 Int24 handler?


In article <918941574.20233.0.rover.d4ee1...@news.demon.nl>,

Quote
The NightmarE <Nightm...@santi.demon.nl> wrote:
>try resetting IOResult in the second part

>IOResult:=0;

I hope you were kidding.

Osmo

Re:Error in BP7 Int24 handler?


On Fri, 12 Feb 1999 13:55:26 +0100, "Jiri Cerny"

Quote
<ce...@NOSPAMchaps.cz> wrote:
> After RT error 150 (Disk is write protected) during Erase non-empty file,
> BlockWrite or Close after write, the program gets the same error (RT150) once
> more (either for next I/O operation, or later). Can you tell me if it is my
> error, BP error or operating system error?

This is a well known problem for almost all "pure" MS-DOS versions.
The reason is the way TP handles INT_$24. It doesn't return to the DOS
handler - as officially required by the MSDOS documentation - but
skips it an returns directly to the application program which invoked
the offending DOS function and "implants" a faked error code to it.

All this happens on undocumented ground and due to informations of
probably Schulman's book Undocumented DOS. After a lot of expirmenting
I've still not found a foolproof way to avoid the terrible "delayed"
error messages - which may occur once or even twice at the command
line _after_ the TP program terminated (!), except by shutting up TP's
handler:

var p:pointer;
procedure myint24;assembler;
asm
  mov ax,3
  iret
end;

...
begin
  getintvec($24,p);setintvec($24,@myint24);
  ....
  setintvec($24,p);

around sequences accessing floppies. This handler will return to DOS
with the message FAIL which will tell DOS to terminate the offending
DOS function with a (possibly obscure) error code. There is a slight
risk, though, that DOS may decide that it cannot terminate reasonably
the offending function and terminates the program instead via INT_$4C.
But I've not yet seen such a case.

In your case (erase file on write-protected disk) the IOResult
returned now will be 2 (file not found) which is not so bad after all.

Regards
Horst

Re:Error in BP7 Int24 handler?


Quote
Osmo Ronkanen wrote in message <7a62g6$...@kruuna.Helsinki.FI>...
>In article <918941574.20233.0.rover.d4ee1...@news.demon.nl>,
>The NightmarE <Nightm...@santi.demon.nl> wrote:
>>try resetting IOResult in the second part

>>IOResult:=0;

>I hope you were kidding.

Of course he was. ;-) What he really meant was "InOutRes := 0".

Jay
--

Jason Burgon - author of Graphic Vision
g...@jayman.demon.co.uk
http://www.jayman.demon.co.uk

Re:Error in BP7 Int24 handler?


Dear Sir/madam,
Would you mind telling me what's the purpose of the following program ?
Thank you for your help!
Nestor King
(E-mail address : hkcee...@net{*word*249}s.net )

program Try;

{ Program to demonstrate Borland Pascal 7.00/MSDOS error (?):
  after error 150 (disk is write protected), some next operation fails
  with error 150 again. }

{$i-}
const
  TryFName = 'a:\TRY.TRY';  { name of existing non-empty file on
write-protected
disk }
  TempFName = 'c:\$$$.$$$'; { name for temporary file that program can
create }

var
  f: file;
  er: Integer;
  i: Integer;
begin
  { try to write to write-protected disk }
  assign (f, TryFName);
  erase (f); er := IOResult;
  writeln ('Erase ',TryFName,': error ',er);

  { perform some operations on TempFName and report errors if any }
  assign (f, TempFName);
  for i := 1 to 100 do begin
    rewrite (f,1); er := IOResult;
    if (er <> 0) then writeln ('Run ',i,': Rewrite error ',er);
    BlockWrite (f, i,sizeof(i)); er := IOResult;
    if (er <> 0) then writeln ('Run ',i,': BlockWrite error ',er);
    close (f); er := IOResult;
    if (er <> 0) then writeln ('Run ',i,': Close error ',er);
    erase (f); er := IOResult;
    if (er <> 0) then writeln ('Run ',i,': Erase error ',er);
  end;
end.

Re:Error in BP7 Int24 handler?


darn ,did I type that... (geeze must be sleepy when I did this).

Quote
Osmo Ronkanen <ronka...@cc.helsinki.fi> wrote in message

news:7a62g6$7vi@kruuna.Helsinki.FI...
Quote
>In article <918941574.20233.0.rover.d4ee1...@news.demon.nl>,
>The NightmarE <Nightm...@santi.demon.nl> wrote:
>>try resetting IOResult in the second part

>>IOResult:=0;

>I hope you were kidding.

>Osmo

Other Threads