Cancel

Top  Previous  Next

Property

Cancel  -- (Boolean)

Access

Readonly

Description

oUTILITIES.Cancel - Will be True if the commando processor profile needs your script to stop running.

 

If your Commando Script contains a lot of looping or repetitive processing, this property will be set in the profile for you to refer to periodically.  If the value is True then your script should immediately stop processing, break out of any loops you are in and raise a CANCEL event using the SMEvent object.

 

For example, if your processor is going to call the PREPROCESS() function and in that function you are connecting to your database and searching for records that need to be exported to HL7 your code might be involved in processing many records.

 

hmtoggle_arrow1Click here for Example Code

 

'Declare the oADO as a public variable

Public oADO

 

Private Sub PollDataBase()

Dim sSQL, dbRS

sSQL = "Select * From Customers"

'Open an ADO Recordset from this SQL statement

Set dbRS = oADO.OpenEditableRS(sSQL)

Do While Not dbRS.Eof

 'Give some CPU time to other running processes

 oUTILITIES.Yield

 '....Code

 '....Code

 '....Code

dbRS.MoveNext

If oUTILITIES.Cancel Then

   SMEvent.Raise "CANCEL", "The processor profile requested that I stop"

   Exit Do

End If

Loop

dbRS.Close

Set dbRS = Nothing

Exit Sub

End Sub 

 

 

Public Function PREPROCESS()

'The main preprocessing function called by the processor profile

  If Not oMSG.Testing Then 

      If Not ConnectToDataBase() Then

           SMEvent.Raise "ERROR", "Error connecting to database"

           PREPROCESS = False

           Exit Function

      End If

      Call PollDataBase

      'Clean up my ADO Connection object

      Set oADO = Nothing

  Else 

     'They are clicking the Test Preprocess() Function button

     Msgbox "I hear and obey", VBINFORMATION, "Test Succeeded"

  End If

 

  PREPROCESS = True

  Exit Function 

End Function

 

Private Function ConnectToDatabase()

Set oADO = New MS_SQLADO

With oADO 

   'Change these next 4 properties to valid values to test"

   .ServerName = oUTILITIES.MyComputerName

   .DatabaseName = "Northwind"

   .UserID = "sa"

   .Password = "password"

   .Timeout = 15

   If Not .Connect() Then

      Set oADO = Nothing 

      ConnectToDatabase = False 

      Exit Function 

   End If  

End With

   ConnectToDatabase = True

End Function

 

 

See the Commando HL7 documentation for further information on how to use Commando HL7:

 

http://www.hermetechnz.com/documentation/Commando/V1/index.html