* Lets build our command that we can then send to the oCheck.CheckCommand method LOCAL lcUseCommand, loCheck, lErrorFlag lcUseCommand = 'USE '+ALLTRIM(lcFileToTest)+' EXCLUSIVE' loCheck = NEWOBJECT('WasError','WasError.PRG') lErrorFlag = loCheck.CheckCommand(lcUseCommand) loCheck.Release() IF lErrorflag * We got the table exclusive so lets close it * and return USE lnReturnValue = 2 ELSE * We could not get the table exclusive lnReturnValue = 1 ENDIF SELECT(lnSelectAreaSave) IF NOT EMPTY(lcSaveDataBase) SET DATABASE TO (lcSaveDataBase) ENDIF RETURN lnReturnValueThe waserror.prg holds:
* WasError.PRG * Example: oCheck = NEWOBJECT('WasError','WasError.PRG') * IsSuccess = oCheck.CheckCommand('USE MyTable EXCLUSIVE') * oCheck.Release() * * Class to determine if a command results in an error DEFINE CLASS WasError AS Relation NoError = .T. && Flag when there's an Error. ErrorNumber = 0 ErrorMessage = '' PROCEDURE CheckCommand LPARAMETERS Command THIS.NoError = .T. &Command. RETURN THIS.NoError ENDPROC PROCEDURE Error LPARAMETERS nError, cMethod, nLine DEBUGOUT STR(nError) + " " + MESSAGE() WITH This .NoError = .F. .ErrorNumber = m.nError .ErrorMessage = MESSAGE() ENDWITH RETURN ENDPROC PROCEDURE Release RELEASE THIS ENDPROC ENDDEFINE