Terminate

This event triggers before a batch closes after processing.

Syntax

ScriptModule_Terminate (ModuleName as String)
Parameter Description
ModuleName Name of the current module.

Possible values

  • Designer
  • Verifier
  • Server

Sample Code

Private Sub ScriptModule_Terminate(ByVal ModuleName as String)
   DB.Close
   Set DB = nothing
End Sub

This script when added to one of the real projects triggers the Terminate event in Runtime Server. This script erases all state 0 batches that contain zero directories. Do not use this script piece together with the corresponding ProcessBatch event script within one project, because this Terminate event script makes it impossible to load the ProcessBatch script.

Private Sub ScriptModule_Terminate(ByVal ModuleName as String)
   On Error GoTo LABEL_ERROR
   Project.LogScriptMessageEx CDRTypeInfo, CDRSeveritySystemMonitoring, "Processing ScriptModule_Terminate event"
   Dim i as Long
   Dim pBatchRoot as New SCBCdrBATCHLib.SCBCdrBatchRoot
   pBatchRoot.ActivateSupport = True
   pBatchRoot.SetConnectionProperties("Job name", "Zero Folder Batch Terminator", False)
   pBatchRoot.Connect("Job name", "", "LOGIN_AS_CURRENT", "", "Zero Folder Batch Terminator")
   pBatchRoot.SetFilter(0)
   For i = 0 To pBatchRoot.BatchCount - 1 Step 1
      If pBatchRoot.FolderCount(i) = 0 Then
         Project.LogScriptMessageEx CDRTypeWarning, CDRSeveritySystemMonitoring, "Zero Folder Batch Terminator detected batch with zero folders: [" & pBatchRoot.BatchID(i) & "]"
         pBatchRoot.DeleteBatch(pBatchRoot.BatchID(i), False, 0, 0)
      End If
   Next i
   Exit Sub
   LABEL_ERROR:
   Project.LogScriptMessageEx CDRTypeWarning, CDRSeveritySystemMonitoring, "Zero Folder Batch Terminator failed to search for zero folder batches. Error description: " & Err.Description
End Sub