[comp.lang.pascal] Drive not ready message

cjveenm@tjalk.cs.vu.nl (Veenman CJ) (04/25/89)

	Question:

When you try to open a file for reading or writing and that file is
on a drive which isn't ready yet, you will get a message that tells you
about your mistake.

Using Turbo Pascal 3 this will happen after the RESET(file) or 
REWRITE(file), but in TP4 it won't. At least when I am doing so.

Why is that?

				Cor Veenman.

ts@chyde.uwasa.fi (Timo Salmi LASK) (04/27/89)

In article <2215@botter.cs.vu.nl> cjveenm@cs.vu.nl () writes:
>	Question:
>When you try to open a file for reading or writing and that file is
>on a drive which isn't ready yet, you will get a message that tells you
>about your mistake.
>Using Turbo Pascal 3 this will happen after the RESET(file) or 
>REWRITE(file), but in TP4 it won't. At least when I am doing so.
>Why is that?

Now I do not know why it is so, but what you should do is to check
for the IOResult yourself in your program at reset or rewrite time:

FileMode := 0;   {to allow testing even protected files}
{I-}
reset(myfile);
{I+}
result := IOResult;

If the result = 152 then the drive is not ready. Simple as that.
(Tested with a Turbo 5.0 program).
...................................................................
Prof. Timo Salmi
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun

pilgrimk@lafcol.UUCP (Kenwyn A. Pilgrim) (04/28/89)

In article <2215@botter.cs.vu.nl>, cjveenm@tjalk.cs.vu.nl (Veenman CJ) writes:
# 
# 	Question:
# 
# When you try to open a file for reading or writing and that file is
# on a drive which isn't ready yet, you will get a message that tells you
> about your mistake.
# 
# Using Turbo Pascal 3 this will happen after the RESET(file) or 
# REWRITE(file), but in TP4 it won't. At least when I am doing so.
# 
# Why is that?
# 

TP40 rets IN24 to its own interrupt procedure, hence 
Disk errors (Drive not ready, file not found, etc) would be treated
like any other I/O error. 
If you don't like this then simply reset INT24 to its original interrupt!
SetIntVec($24, SaveInt24);
See p291. of TP40 manual

-Kenwyn