Script Locator
The
Script Locator runs a custom script routine that produces:
-
A set of alternatives, each with a single result (similar to a Format Locator) or
-
A set of alternatives, each with subfield results (similar to the Advanced Zone Locator)
The script can use the XDoc to retrieve data from locators that have run before it, create its own values, or use a combination of both.
For each Script Locator, an event is fired and a configurable script function is executed when Server runs.
Manage a Script Locator in the following ways:
Using the Script Viewer enables you:
-
Insert the script function
-
Create results for a simple field Script Locator
-
Create results for a group field Script Locator
If the Script Locator uses input from other locators or evaluators, run those locators before testing the Script Locator. Dependent locators are not processed and therefore needed input data may not be available. To run a dependent locator, open the locator properties and click Test, or press F7 for a test document to run the complete extraction.
In order for confidence values to be passed with the Script Locator when feeding another locator, the script must include an alt.LongTag = 10000 statement in the code.
For example,
Private Sub ProcessDates(pXDoc As CASCADELib.CscXDocument, pLocator As CASCADELib.CscXDocField, minConfidence As Double)
On Error GoTo CatchError
Dim locKey As CscXDocField
Set locKey = pXDoc.Locators.ItemByName("FL_Dates")
Dim i As Integer
Dim keyAlt As CscXDocFieldAlternative
Dim lineIndex As Integer
Dim wordIndex As Integer
For i = 0 To locKey.Alternatives.Count - 1
Set keyAlt = locKey.Alternatives(i)
If keyAlt.Confidence > minConfidence Then
Dim validDate As Boolean
Dim formattedText As String
Dim errDesc As String
validDate = Project.FieldFormatters.ItemByName("CustomDateFormatter").FormatFieldText(keyAlt.Text, formattedText, errDesc)
If validDate Then
Dim alt As CscXDocFieldAlternative
Set alt = pLocator.Alternatives.Create
Dim j As Integer
For j = 0 To keyAlt.Words.Count - 1
alt.Words.Append(keyAlt.Words(j))
Next
alt.Text = formattedText
alt.Confidence = keyAlt.Confidence
alt.LongTag = 10000
End If
End If
Next
Exit Sub
CatchError:
Debug.Print("***ERROR*** ProcessDates" & Err.Description)
End Sub
The Properties of Script Locator window has the following tabs:
-
Field Definition tab
-
Regions tab
-
Test Results tab