Create results for a group field Script Locator
In the following example, an
Advanced Zone Locator is configured to extract a full name such as “Bruce Matthews”. The
Script Locator retrieves this result and splits the name into a subfield for the first name and a
subfield for the last name, for example,
Bruce
Matthews
.
You can create results for a group field by following these steps:
-
Create one or more alternatives as follows:
pLocator.Alternatives.Create
-
Create subfields for each alternative.
pLocator.Alternatives(<N>).Subfields.Create(<Subfield Name>)
Note Make the subfield names match those defined on the Field Definition tab. -
In combination with additional logic, use the results from other locators to create the required values within the
Script Locator. Retrieve results from other locators as follows:
pXDoc.Locators.ItemByName(<Locator Name>).Alternatives(<N>).Text
This example retrieves the alternative with index N from a locator producing multiple single-result alternatives, such as a Format Locator.
pXDoc.Locators.ItemByName(<Locator Name>).Alternatives(<N>).Subfields.ItemByName(<Subfield Name>).Text
This example retrieves a subfield result from a locator producing multiple subfields per alternative, such as an Advanced Zone Locator.
-
Assign text values to the
Script Locator subfields.
pLocator.Alternatives(<N>).Subfields.ItemByName(<Subfield Name>).Text = <TextValue>
-
Assign confidence values (between 0 and 1) to the
Script Locator subfields.
pLocator.Alternatives(<N>).Subfields.ItemByName(<Subfield Name>).Confidence = <ConfidenceValue>
-
If required, assign co-ordinate values (in pixels) to the alternatives in the
Script Locator subfields.
pLocator.Alternatives(<N>).Subfields.ItemByName(<Subfield Name>).Top = <Top Coordinate>
pLocator.Alternatives(<N>).Subfields.ItemByName(<Subfield Name>).Left = <Left Coordinate>
pLocator.Alternatives(<N>).Subfields.ItemByName(<Subfield Name>).Height = <Height>
pLocator.Alternatives(<N>).Subfields.ItemByName(<Subfield Name>).Width = <Width>