This example shows a unified script that can run at the form level. It cleans up the data before verification and flags fields that do not conform to the following rules:
-
In zones with a Zone Name beginning with "TAPE", the following edit masks need to be applied based on the length of the data in the zone:
-
Length of 4: A999
-
Length of 7: 999999A
-
Length of 8: X999999A
-
Length of 0: Replace with "00000000"
-
-
In zones with a Zone Name of "T##" (where ## is a two digit number), replace the data with 24 zeroes if the zone is blank.
-
The zone names begin with "Tape" or be "T##."
-
"TAPE" Zones that do not contain 0, 4, 7 or 8 characters are flagged for keying.
Zones that do not follow these patterns will be ignored by the script.
GUI Product Features Used in this Script:
-
Parameters Toolbox button | Data Definition Parameters | Zone Name is the key product feature being leveraged in this script.
Key VB Script Features Demonstrated in this Script:
-
Regular Expression Object (VB Script)
-
ApplyEditMask Method (OCR for AnyDoc)
-
Name Property (OCR for AnyDoc)
-
Representation of a Zone as an Object
Example Script:
'Level: Form
'Phase: Post Extract/PreVerify
'Set up regular expressions
Set re = New regexp
Set re2 = New regexp
re.ignorecase = True
re2.ignorecase = True
'For strings begining with "TAPE..."
re.pattern = "^Tape"
'For strings of "T##" with nothing after
re2.pattern = "^T\d{1,2}$"
'roll thru zones. If Zone Name begins with "TAPE" the apply masks based on size. If T## then replace blanks with 23 zeroes.
For xx = 1 To Form.ZoneCount
Set objZone = Form.Zone(xx)
strZone = objZone.Name
strValue = objZone.Value
If re.test(strZone) Then
Select Case Len(strValue)
Case 0
objZone.Value = "00000000"
Case 4
objZone.ApplyEditMask("A999")
Case 7
objZone.ApplyEditMask("999999A")
Case 8
objZone.ApplyEditMask("X999999A")
Case Else
objZone.Flagged = True
End Select
ElseIf re2.test(strZone) Then
If Len(strValue) = 0 Then objZone.Value = "00000000000000000000000"
End If
Next
Set objZone = Nothing
Set re = Nothing
Set re2 = Nothing