: [c:\nightly\progs\roll forward due dates.prg] Error#: 1951Line #: 3: Cannot clear the object MYRUNNER because it is in use. 07/14/2006 02:30:38 PMSome Code:
&& JWN - 07/14/06 02:49:41 PM && Run Scheduled Jobs Close Tables All Close Databases All Clear All Release All Set Classlib To Set Deleted On Set Exclusive Off Set Safety Off ON ERROR Local lnId, lnNumrecs, lcAppToRun, llJobEnabled Use l:\Shared\nightcontrol In 0 Order joborder cAppToRun = '' DO CreateNightLogEntry Select nightcontrol lnNumrecs = Reccount() Scan lnId = nightcontrol.Id llJobEnabled = nightcontrol.jobenabled lcAppToRun = Alltrim(nightcontrol.prgname) If llJobEnabled LogProgress(CHR(13)+[: ]+lcAppToRun+CHR(13)) SELECT nightcontrol REPLACE laststart WITH DATETIME() oRunner = Createobject("myrunner") oRunner.RunProgram(lcAppToRun) Release oRunner SELECT nightcontrol REPLACE lastend WITH DATETIME() LogProgress( Alltrim( Ttoc( Datetime() ) ) + Chr( 13 ) ) Endif Endscan Do MyCleanup && Procedures PROCEDURE CreateNightLogEntry Use l:\shared\nightlog In 0 Select nightlog Append Blank TMPDATE = Datetime() Replace start_date With TMPDATE Use ENDPROC Function LogProgress( cStr ) OpenLog() Select nightlog Go Bottom Replace Detail With Detail + cStr Endfunc *!* Function: OpenLog() *!* Description: Opens the log file *!* Date: 07/16/01 Function OpenLog() Open Database l:\Database\Shared If !Used( "nightlog" ) Use nightlog In 0 Order Id Endif Endfunc Procedure MyCleanup If Used('nightcontrol') Select nightcontrol Use Endif If Used('nightlog') Select nightlog Use Endif Endproc Define Class myrunner As Session OlePublic Procedure Init Close Tables All Close Databases All Set Classlib To Set Deleted On Set Exclusive Off Set Safety Off Endproc Procedure Destroy Close Tables All Close Databases All Set Classlib To Set Deleted On Set Exclusive Off Set Safety Off Endproc Procedure RunProgram Lparameters cProg Local cMsg, nLine, nErrnum, cError Try Do &cProg Catch To loException * Debug * Suspend nErrnum = loException.ErrorNo cMsg = loException.Message nLine = loException.Lineno cError = Chr(13)+ ; "Error#: " + ; Alltrim(Str(nErrnum)) + ; "Line #: "+ Alltrim(Str(nLine)) + ; ": " + Alltrim(cMsg) + ; Chr(13) This.LogProgress(cError) Endtry Endproc Procedure LogProgress Lparameters cStr This.OpenLog() Select nightlog Go Bottom Replace Detail With Detail+cStr ENDPROC Function OpenLog() Open Database l:\Database\Shared If !Used( "nightlog" ) Use nightlog In 0 Order Id Endif Endfunc Enddefine