IFreeTextComparer.ForEachWord

Syntax

ForEachWord: Boolean;

Description

The ForEachWord property determines whether to compare on occurrence either a single word separately, or all words simultaneously.

Comments

Default property value is False.

Example

To execute the example, add a link to the Collections system assembly in assemblies inspector.

Sub Main;
    
Begin
    TestCompare("Perm area""Perm Krai");
    TestCompare("Perm area""Moscow area");
    TestCompare("Perm area""Moscow Krai");
End Sub Main;

Function TestCompare(x: String; y: String): Integer;
Var
    pComparer: IComparer;
    FreeComparer: IFreeTextComparer;
    iResult: Integer;
Begin
    pComparer := Comparer.FreeTextComparer;
    FreeComparer := pComparer As IFreeTextComparer;
    FreeComparer.ForEachWord:= True;
    iResult := FreeComparer.Compare(x, y);
    Select Case iResult
        Case 0: Debug.WriteLine("'" + x + "'  '" + y + "' -> one of the words is included into the string to be found");
        Case -1,1: Debug.WriteLine("'" + x + "'  '" + y + "' -> neither of the words is included into the string to be found");
    End Select;
    Return iResult;
End Function TestCompare;

After executing the example comparison results are displayed in the console window:

'Perm area'  'Perm Krai' -> one of the words is included into the string to be found
'Perm area'  'Moscow area' -> one of the words is included into the string to be found
'Perm area'  'Moscow Krai' -> neither of the words is included into the string to be found

See also:

IFreeTextComparer