CreateGlobalObject (Method) - OCR for AnyDoc - Foundation 23.1 - Foundation 23.1 - AnyDoc - external

OCR for AnyDoc Programming Reference Guide

Platform
AnyDoc
Product
OCR for AnyDoc
Release
Foundation 23.1
License

Description

Use this method to access other applications' objects from within OCR for AnyDoc. The combination of the user-assigned value and the program ID uniquely creates access to the application. The first time a particular user-assigned value and program ID are used, a connection is created. In subsequent uses, the connection is retrieved.

Global functions persist independently on different workstations (in RAM) until OCR for AnyDoc is closed or until the connection with the object is destroyed with the DeleteGlobalObject function.

Applicable Events

Post Extract, AnyApp Post Extract, Pre-Verify, Interactive, Verification Function Key (F-Key), Post-Verify

Syntax

object.CreateGlobalObject (intUserAssignedValue,strProgramID)

Parameters

Object is a reference to the Application object. For more information, see Application Object (page Application Object).

CreateGlobalObject is the command.

intUserAssignedValue is a numerical value of your choice.

strProgramID is the program ID. To locate program IDs, consult the application documentation.

Example

'Do the database lookup here, and populate the areas from File

'First item is to get the Control Number

strLookup = Mid(strNo, 7, 9)

'Create the database session and check to see if exists

Set objDb = CreateGlobalObject(1, "ADODB.Connection")

If GlobalObjectIsNew(1, "ADODB.Connection") = True Then

objDb.provider = "MSDASQL"

objDb.Open "DBName", "xxx", "xxx"

End If

'take data from lookup and see if you get a hit

strQuery = "SELECT * FROM xxxtable WHERE ControlNumber = '" & strLookup & "'"

Set objRecordSet = objDb.Execute(strQuery)

If Not objRecordSet.EOF Then

'MsgBox "Found Record"

Label.Hidden = True

Hit.Value = "Y"

'Populate the address parts from file

'LastName zone

strTemp = trim(objRecordSet.Fields(1).Value)

If strTemp <> "" Then

LName.Value= strTemp

End If

'FirstName zone

strTemp = trim(objRecordSet.Fields(2).Value)

If strTemp <> "" Then

FName.Value= strTemp

End If

'MsgBox FName.Value

'MiddleInitial zone

strTemp = trim(objRecordSet.Fields(3).Value)

If strTemp <> "" Then

MI.Value= strTemp

End If

'Address1

strTemp = trim(objRecordSet.Fields(8).Value)

If strTemp <> "" Then

Add1.Value= strTemp

End If

'Address2

strTemp = trim(objRecordSet.Fields(9).Value)

If strTemp <> "" Then

Add2.Value= strTemp

End If

'City

strTemp = trim(objRecordSet.Fields(10).Value)

If strTemp <> "" Then

City.Value= strTemp

End If

'State

strTemp = trim(objRecordSet.Fields(11).Value)

If strTemp <> "" Then

State.Value= strTemp

End If

'Zip

strTemp = trim(objRecordSet.Fields(12).Value)

If strTemp <> "" Then

Zip.Value= strTemp

End If

Else 'What if no match to file - flow says to key label

'MsgBox "did not match"

End If

'Need to close and destroy the connection if we're all done!

If Form.CurrentBatchPage = Form.TotalBatchPages Then 'end of batch

objDb.close

Set objDb = Nothing

DeleteGlobalObject 1, "ADODB.Connection"

End If