Select Hand Print or Machine Print Address Block & Validate with AccuZip - 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

In this example, a customer can either affix a pre-printed label to the form or if they do not have a pre-printed label, then a drop out handprint address block must be completed.

On the Master form, there are individual text zones for the handprint information and a large text zone on the left side of the box for a label. A VBScript will choose between using the handprint zones or the machine print zone for extracting the address, and each will call AccuZip as needed to validate the address.

When completing the form manually, the handprint is dropped out of the data image. Both the titles and the constraint boxes were printed in red and dropped out during scan.

When the label is affixed to the form, the machine print is dropped out. Here, the customer placed a pre-printed label on the form instead of filling out the handprint inputs. The label was placed on the form crooked.

In this script, use of the machine print and handprint areas was restricted to the same area on the form. Other applications could have separate areas for this information, which could make the scripting a little easier.

In the event that the script cannot determine if it has a machine print or hand print address, it will hide the label and will prompt the operator to key in each handprint field.

AccuZip is being called via script to validate the address. It is also being used to normalize it. In actuality, the best reason to call AccuZip via script is to validate the address without normalizing it. This example shows all fields being written back by AccuZip. However, it would be more realistic to only write back to the ZIP field (to get the +4 or to update the number) and leave the street address, city, and State alone (if desired).

The script is written from a strict rule enforcement viewpoint - the address must be confirmed by AccuZip as valid before the Verify operator can release it. For more information about creating a workaround in this kind of script, seeSend Image to Supervisor After Three Attempts (page Send Image to Supervisor After Three Attempts).

Since this script is being applied to constrained, drop out handprint, a cleanup function has been applied in the Constants section that is being called to ensure the zone is truly blank.

GUI Product Features Used in this Script:

  • Intelligent Address Extraction must be applied to the label zone. To For/Next through a single zone address block (i.e., a zone that had Intelligent Address Extraction applied to it) or to apply AccuZip via scripting to it, the easiest way to figure out where the address components are is to renumber the components you are outputting, then write down their line numbers.

  • Parameters | Form Removal | Advanced| Deskew Zone Based on Character Data should be enabled for the machine print label zone only.

Key VB Script Features Demonstrated in this Script:

  • Use of a Function in Constants (VB Script/OCR for AnyDoc)

  • Use of a Preverify Script to Hide/Flag/Validate (OCR for AnyDoc)

  • Use of a Post Verify Script to Validate/Flag/Enforce a Rule (OCR for AnyDoc)

  • ApplyEditMask Method (OCR for AnyDoc)

  • Replace Method (VB Script)

  • Len Property (VB Script)

  • .hidden Property (OCR for AnyDoc)

  • .flagged Property (OCR for AnyDoc)

  • .CustomMessage Method (OCR for AnyDoc)

  • .AccuZip Fields Objects (OCR for AnyDoc)

  • .AccuZip Process Method (OCR for AnyDoc)

  • Hiding one set of fields or another based on a set of criteria

Example Script: Constants

The function below is used to remove 1's, pipes, I's, and spaces from handprint data is see if there is any data remaining - this can be done to ensure that no part of the background form is coming through and being misread as data.

Function LenAfterCleanUp(ByVal strTemp)

strTemp = Replace(strTemp, "1", "")

strTemp = Replace(strTemp, "|", "")

strTemp = Replace(strTemp, "I", "")

strTemp = Replace(strTemp, " ", "")

LenAfterCleanUp = Len(strTemp)

End Function

Example Script: Preverify

'Script to choose between handprint and label zones for address

'Also uses Accuzip to validate address

Dim blnFlagHP, blnHideHP, blnHideMP, blnAccuzip, strMessage, xx, strTemp, iCountZn, yy, iCountLn, aa, bb

'initialize variables

blnFlagHP = False

blnHideHP = False

blnHideMP = False

blnAccuzip = False

strMessage = ""

'Spin thru and see if there is data

For xx = 4 To 7

strTemp = Form.Zone(xx).Value

If LenAfterCleanUp(strTemp) < 2 Then

iCountZn = iCountZn + 1

End If

Next

'If no data, then check for data in label

If iCountZn > 1 Then

For yy = 1 To zLabel.LineCount

strTemp = zLabel.Line(yy).Value

If LenAfterCleanUp(strTemp) < 2 Then

iCountLn = iCountLn + 1

End If

Next

If iCountLn > 4 Then

'Both Failed

'Flag all HP for data entry

blnFlagHP = True

'Hide all MP

blnHideMP = True

'No AccuZIP

blnAccuzip = False

'Custommessage

strMessage = "No Data Found - please enter data."

Else

'Label Present

'hide all HP

blnHideHP = True

'Run machineprint thru AccuZIP

blnAccuzip = True

End If

Else

'Run HP thru AccuZip

blnAccuzip = True

'hide all MP

blnHideMP = True

End If

For aa = 1 To 7

Form.Zone(aa).Hidden = blnHideHP

Form.Zone(aa).Flagged = blnFlagHP

Form.Zone(aa).CustomMessage = strMessage

Next

For bb = 1 To zLabel.LineCount

zLabel.Line(bb).Hidden = blnHideMP

Next

If blnAccuzip Then

If blnHideMP Then

'List HP items here

AccuZip.AddressField = zAddress.Value

AccuZip.CityField = zCity.Value

AccuZip.StateField = zState.Value

AccuZip.ZipField = zZIP.Value

If AccuZip.Process Then

zAddress.Value = AccuZip.AddressField

zCity.Value = AccuZip.CityField

zState.Value = AccuZip.StateField

zZIP.Value = AccuZip.ZipField

Else

For xx = 4 To 7

Form.Zone(xx).Flagged = True

Form.Zone(xx).CustomMessage = "Not validated by AccuZIP: Please Correct."

Next

End If

Else

'List MP items here

AccuZip.AddressField = zLabel.Line(4).Value

AccuZip.CityField = zLabel.Line(5).Value

AccuZip.StateField = zLabel.Line(6).Value

AccuZip.ZipField = zLabel.Line(7).Value

If AccuZip.Process Then

zLabel.Line(4).Value = AccuZip.AddressField

zLabel.Line(5).Value = AccuZip.CityField

zLabel.Line(6).Value = AccuZip.StateField

zLabel.Line(7).Value = AccuZip.ZipField

Else

For yy = 4 To 7

zLabel.Line(yy).Flagged = True

Form.Zone(yy).CustomMessage = "Not validated by AccuZIP: Please Correct."

Next

End If

End If

End If

Example Script: Post Verify

This script will ensure the address block that was found is valid via AccuZip

Dim blnHideHP, blnHideMP, xx, yy

If zAddress.Hidden = True Then

blnHideHP = True

ElseIf zLabel.Line(1).Hidden = True Then

blnHideMP = True

End If

If blnHideMP Then

'List HP items here

AccuZip.AddressField = zAddress.Value

AccuZip.CityField = zCity.Value

AccuZip.StateField = zState.Value

AccuZip.ZipField = zZIP.Value

If AccuZip.Process Then

'If you are validating but not normalizing comment out the following 4 lines

zAddress.Value = AccuZip.AddressField

zCity.Value = AccuZip.CityField

zState.Value = AccuZip.StateField

zZIP.Value = AccuZip.ZipField

Else

For xx = 4 To 7

Form.Zone(xx).Flagged = True

Form.Zone(xx).CustomMessage = "Not validated by AccuZIP: Please Correct."

Next

End If

ElseIf blnHideHP Then

'List MP items here

AccuZip.AddressField = zLabel.Line(4).Value

AccuZip.CityField = zLabel.Line(5).Value

AccuZip.StateField = zLabel.Line(6).Value

AccuZip.ZipField = zLabel.Line(7).Value

If AccuZip.Process Then

'If you are validating but not normalizing comment out the following 4 lines

zLabel.Line(4).Value = AccuZip.AddressField

zLabel.Line(5).Value = AccuZip.CityField

zLabel.Line(6).Value = AccuZip.StateField

zLabel.Line(7).Value = AccuZip.ZipField

Else

For yy = 4 To 7

zLabel.Line(yy).Flagged = True

Form.Zone(yy).CustomMessage = "Not validated by AccuZIP: Please Correct."

Next

End If

End If