BBC BASIC for Windows
« Disc drive check »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:11pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Disc drive check  (Read 672 times)
TheFamousCash
New Member
Image


member is offline

Avatar




PM


Posts: 16
xx 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.

User IP Logged

rtr2
Guest
xx 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.

User IP Logged

TheFamousCash
New Member
Image


member is offline

Avatar




PM


Posts: 16
xx 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.
User IP Logged

sveinioslo
Developer

member is offline

Avatar




PM


Posts: 64
xx 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
 

User IP Logged

rtr2
Guest
xx 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:
      SYS "DeleteFile", file$ 

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 » User IP Logged

sveinioslo
Developer

member is offline

Avatar




PM


Posts: 64
xx 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
User IP Logged

TheFamousCash
New Member
Image


member is offline

Avatar




PM


Posts: 16
xx 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




User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls