Author |
Topic: Disc drive check (Read 672 times) |
|
TheFamousCash
New Member
member is offline


Posts: 16
|
 |
Disc drive check
« Thread started on: Mar 13th, 2015, 9:38pm » |
|
I run a program which requires to delete a file if it is on disc. Using "openup" to check if file is there produces error if drive empty as does SYS "FindFirstFile". Please could someone advise how I check if there is a disc in the drive without generating an error? Thanks.
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Disc drive check
« Reply #1 on: Mar 13th, 2015, 10:21pm » |
|
on Mar 13th, 2015, 9:38pm, TheFamousCash wrote:Please could someone advise how I check if there is a disc in the drive without generating an error? |
|
This doesn't answer your question, but I should point out that even if such a test exists it doesn't really help. There will always be a finite time window between you performing the test and attempting to delete the file, during which the disc could have been ejected. In that (admittedly unlikely) event you're back to square one.
Getting back to the problem, are you specifically referring to floppy discs? I don't think that SYS "DeleteFile" generally does generate an error if a removable disc (e.g. CD-ROM) is missing, but floppies are an exception.
Read this Raymond Chen blog post for some background:
http://blogs.msdn.com/b/oldnewthing/archive/2009/04/02/9528175.aspx
Richard.
|
|
Logged
|
|
|
|
TheFamousCash
New Member
member is offline


Posts: 16
|
 |
Re: Disc drive check
« Reply #2 on: Mar 16th, 2015, 02:21am » |
|
Richard, Many thanks for your response. Speaking of CDs containing programs in normal PC disc drive. I found one of your functions which works perfectly:- IFCD$="D"SYS "DeleteFile", src$+$fpt%, dst$+$fpt%, 0 TO res% IFCD$="C"SYS "CopyFile", src$+$fpt%, dst$+$fpt%, 0 TO res% However, if there is no disc in the drive, an error is generated showing "No disc is in drive". I cannot find a method to circumvent this problem. (*CD, *DIR et cetera and attempting to see a file is on disc by using OPENUP, all generate the error.) I thought I had settings which advised by email when a reply had been posted but just found your response in double-checking. Thanks, Bob.
|
|
Logged
|
|
|
|
sveinioslo
Developer
member is offline


Posts: 64
|
 |
Re: Disc drive check
« Reply #3 on: Mar 18th, 2015, 12:16pm » |
|
Maybe this proc does the trick ?
Svein
Code:
DEF PROCdeletefile(file$)
ON ERROR LOCAL : ENDPROC
OSCLI "DEL "+file$
ENDPROC
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Disc drive check
« Reply #4 on: Mar 18th, 2015, 1:03pm » |
|
on Mar 18th, 2015, 12:16pm, sveinioslo wrote:Maybe this proc does the trick ? |
|
Or, more straightforwardly (and no need for a PROC):
Code: But I already suggested that to the OP, and he said he tried it, so probably the error message he is referring to is a popup window like the one you get with a missing floppy.
Richard.
|
« Last Edit: Mar 18th, 2015, 1:04pm by rtr2 » |
Logged
|
|
|
|
sveinioslo
Developer
member is offline


Posts: 64
|
 |
Re: Disc drive check
« Reply #5 on: Mar 18th, 2015, 9:55pm » |
|
I was hoping that the "No disc is in drive" error was trappable. Can't test it at my current location.
Svein
|
|
Logged
|
|
|
|
TheFamousCash
New Member
member is offline


Posts: 16
|
 |
Re: Disc drive check
« Reply #6 on: Mar 19th, 2015, 12:21pm » |
|
Many thanks for assistance. I have found solution. Cycling through to discover which LT$ is actual disc drive using below PROC and checking to see if file$ present. If CDFLAG%=1 then simple OSCLI "DEL """+file$+"""" completes.
DEFPROCCHECKDISK(LT$) ON ERROR LOCAL:ENDPROC OSCLI "CD """+LT$+"""" LOCAL dir%, sh%, res% DIM dir% LOCAL 317 SYS "FindFirstFile", "*", dir% TO sh% IFsh%<>-1P%=OPENUPfile$:IFP>0CDFLAG=1:CLOSE#P% ENDPROC
|
|
Logged
|
|
|
|
|