Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I test if there is a diskette in drive a: ?
Message
 
 
À
12/02/1997 05:04:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00020148
Message ID:
00020373
Vues:
39
>Dear Visual FoxPro users
>
>How do I test if there is a diskette in drive a: ?
>I got an error message in win95 if I use SET DEFAULT a and don't have a diskette in drve a: .

OK it dont get no better than the UT!!!!! This was probably my hardest VFP task. That is making it work without the fail, abort, retry screen.

Michel, you may want to add this to the tips section.
*******************************************
*** Procedur to determin drive status   ***
*******************************************
PROCEDURE zFlopOut
PARAMETERS zDriveLetter
Private all like n*, nlasterror, zFormatted, zFlopOut, zGotFiles
nFiles=0
DDRIVE = SET('DEFA')

zFormatted = .F.
zFlopOut =.F.
zGotFiles = .F.


 DECLARE SetErrorMode IN "kernel32.dll" INTEGER mode
 DECLARE INTEGER SetLastError IN "Kernel32.dll" INTEGER flags
 DECLARE INTEGER GetLastError IN "Kernel32.dll"
 DECLARE INTEGER FormatMessage IN "kernel32.dll" INTEGER flags, INTEGER;
 notused, INTEGER error, INTEGER locale, STRING @buffer, INTEGER bufsize,;
 INTEGER notused

 = SetLastError(0)    && The this and the next are crucial to avoid
 = SetErrorMode(1)    && the OS's fail, abort, retry dialog.

zOldError = ON('ERROR')     && Get existing error handler
on error * 					&& Do nothing let the system handler go
 
nFiles = ADIR(afiles, zDriveLetter +"\*.*", 'DFL') && Try to access the drive in question
release afiles                         && This is not needed free up resources

on error &zOldError 				&& Reset old error handler

* IF nFiles = 0
	 nLastError = GetLastError()
	 cError = SPACE(255)
	  = FormatMessage( 4096, 0, nLastError, 0, @cError, 255, 0)
	 cError = ALLTRIM(STRTRAN( cError, CHR(0)))

	 = SetErrorMode(0)  && Make sure to reset the OS error
	 = SetLastError(0)  && handler. VERY IMPORTANTE!!!
* ENDIF


	DO CASE

		CASE nFiles > 0 .OR. nLastError = 18
			zGotFiles = .T.
	   		zFormatted = .T.

		CASE nLastError = 2
	   		zFormatted = .T.

		CASE nLastError = 21
		   zFlopOut = .T.

		CASE nLastError = 31
		    zFormatted = .F.
		
	ENDCASE		

RETURN( zFormatted, zFlopOut, zGotFiles )
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform