Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TRY-CATCH Error handling with Floppy Disk
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01284220
Message ID:
01284446
Views:
9
Great. Just wondering why do you have a message
MESSAGEBOX("No floppy-disk present or insufficient space to save.",0,"Floppy-Disk Error")

if this is the first case only? <g>

>>
>>You're welcome. I had the same problem in 2000? It was a solution that time.
>
>I modified the final code... here is the full version....
>
>At the start of the method....
>
>
>*TMT 01/22/2008
>*-- SetErrorMode determines whether the system handles
>*-- serious errors or whether the program handles them.
>#define SEM_FAILCRITICALERRORS      0x0001
>DECLARE INTEGER SetErrorMode in win32api INTEGER
>*TMT
>
>
>Then later at the end of the method...
>I am copying a file named YYYYMMDD.dat from the C: drive root to the A: drive...
>lcSource = "C:\YYYYMMDD.dat"
>
>* If drive A is selected, copy to a and delete from c
>IF lcDrive == "A"
>	lcSource = "c:\" + ALLTRIM(ThisForm.txtReportName.value)
>	lcDest = "a:\" + ALLTRIM(ThisForm.txtReportName.value)
>	ThisForm.txtStatus.value = "Copying to drive A:..."
>
>*-- SetErrorMode returns what the flags were last set.
>	lnOldMode = SetErrorMode(SEM_FAILCRITICALERRORS)
>*-- Get the size of the DAT file on the C: drive root
>	=ADIR(aDATs,lcSource)
>	DO CASE
>*-- Test the FoxPro DISKSPACE() function.  If you get a -1, then
>*-- there is no disk in the drive.
>		CASE DISKSPACE("a:",1) = -1
>   			MESSAGEBOX("No floppy-disk present or insufficient space to save.",0,"Floppy-Disk Error")	
>*-- Test the free space on the floppy disk to the size of the DAT file on the C: root
>		CASE DISKSPACE("a:") < aDATs(1,2)
>   			MESSAGEBOX("Insufficient space to save on floppy-disk.  Please try another floppy-disk.",0,"Floppy-Disk Error")	
>*-- Otherwise ok... save the file to the floppy disk...
>		OTHERWISE
>			TRY
>				COPY FILE (lcSource) TO (lcDest)
>			CATCH
>	   			MESSAGEBOX("Cannot save to floppy-disk.  Check write-protect on floppy.",0,"Floppy-Disk Error")	
>			FINALLY
>			ENDTRY
>	ENDCASE
>*-- Restore system error handling settings.
>	= SetErrorMode(lnOldMode)
>*TMT
>	DELETE FILE (lcSource)
>ENDIF
>
>
>I added a check for diskspace on the floppy and to check for the write-protect being on.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform