*-- Check that the PARAMETERS is in the correct format.
IF SUBSTR(lsDrive, 2, 1) <> ":" OR ;
(ASC(UPPER(SUBSTR(lsDrive, 1, 1))) < 65 OR ;
ASC(UPPER(SUBSTR(lsDrive, 1, 1))) > 90)
=MESSAGEBOX("Drive must be in the format <drive letter>:", ;
0, "Error"
RETURN -1
ENDIF
*-- SetErrorMode determines whether the system handles
*-- serious errors or whether the program handles them.
DECLARE INTEGER SetErrorMode IN win32api INTEGER
*-- SetErrorMode returns to what the flags were last set.
*-- You need to store this in lnResult so that you can set them
*-- back the way they were before calling SetErrorMode.
*-- Failure to do so can produce unpredictable results
*-- when encountering future errors. SetErrorMode only
*-- applies to the current process and therefore only affects
*-- the FoxPro program that called SetErrorMode.
lnResult = SetErrorMode(SEM_FAILCRITICALERRORS)
Following code comes from an application, so will need modification as it is checking all drives and updating a table.
lcCurrentDir = SYS(5) + CURDIR() && Current folder
ON ERROR lValidDrive = .F.
lValidDrive = .T.
FOR lnDrive = 65 TO 90 && Drives A - Z
[tab]lcDrive = CHR(lnDrive)
[tab]SET DEFA TO (lcDrive) && Attempt to logon to drive
[tab]IF lValidDrive
[tab][tab]INSERT INTO DRIVES (drive, checked);
[tab][tab][tab]VALUES (lcDrive + [:\],.T.)
[tab]ENDIF
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.