This script locator will check the BC_DocumentID alternatives and ensure that only correct alternatives exist. Valid alternatives will be identified using a regular expression
Private Sub SL_DocumentID_LocateAlternatives(ByVal pXDoc As CASCADELib.CscXDocument, ByVal pLocator As CASCADELib.CscXDocField)
On Error GoTo ErrorHandler
OutputDebugString "KfxKTM_SL_DocumentID_LocateAlternatives: Fired"
' ** This script locator will check the BC_DocumentID alternatives and ensure that only correct alternatives exist
' ** Valid alternatives will be identified using a regular expression
Dim oBarcodeLocator As CASCADELib.CscXDocField
Dim iLocAltCounter As Integer
Dim sBarcodeRegex As String
Set oBarcodeLocator = pXDoc.Locators.ItemByName("BC_DocumentID")
sBarcodeRegex = Project.ScriptVariables.ItemByName("Regex_KTM_DocumentID").Value
iLocAltCounter = 0
If Not SSTools Is Nothing Then
If oBarcodeLocator.Alternatives.Count > 0 Then
' Loop through each alternative, checking the barcode value against a regular expression. Removing the alternative where the value is not valid.
While iLocAltCounter < oBarcodeLocator.Alternatives.Count
If SSTools.DoesRegexPatternMatchString(sBarcodeRegex, oBarcodeLocator.Alternatives.ItemByIndex(iLocAltCounter).Text) = False Then
oBarcodeLocator.Alternatives.Remove(iLocAltCounter)
Else
oBarcodeLocator.Alternatives.ItemByIndex(iLocAltCounter).Confidence = 1
End If
iLocAltCounter = iLocAltCounter + 1
Wend
End If
End If
Exit Sub
ErrorHandler:
General_Error_Handler("SL_DocumentID_LocateAlternatives", LOG_ERROR, DISPLAY_TO_USER)
End Sub