Skip to content

IGR_Text_Compare_Close

Closes the text comparison enumerator and frees associated resources.

Prototype

IGR_RETURN_CODE IGR_Text_Compare_Close(
    IGR_HTEXTCOMPARE enumerator,
    Error_Control_Block* error
)

Parameters

enumerator: IGR_HTEXTCOMPARE

The text comparison enumerator to close.

error: Pointer to Error_Control_Block

Contains any error text.

Return value

Success: IGR_LONG

Returns IGR_OK.

Failure: IGR_LONG

Returns one of the possible IGR_E error codes.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <DocumentFilters.h>
#include <string.h>
#include <string>

#define UCS2(src) reinterpret_cast<const IGR_UCS2 *>(std::u16string(src).c_str())

int main(int argc, char **argv)
{
    Instance_Status_Block isb = {0};
    Error_Control_Block ecb = {0};
    IGR_LONG caps, type, pageCount = 0;
    IGR_HDOC doc1_handle = 0, doc2_handle = 0; 
    IGR_HPAGE doc1_page1_handle = 0, doc2_page1_handle = 0;
    IGR_HTEXTCOMPARE compare = 0;

    strncpy(isb.Licensee_ID1, "License Code", sizeof(isb.Licensee_ID1) - 1);
    Init_Instance(0, ".", &isb, &df, &ecb);

    if ((res = IGR_Open_File_Ex(UCS2(u"original.doc"), IGR_FORMAT_IMAGE, UCS2(u""), &caps, &type, &doc1_handle, &ecb)) == IGR_OK
        && (res = IGR_Open_File_Ex(UCS2(u"revised.doc"), IGR_FORMAT_IMAGE, UCS2(u""), &caps, &type, &doc2_handle, &ecb)) == IGR_OK)
    {
        IGR_Text_Compare_Settings settings = { sizeof(IGR_Text_Compare_Settings) };
        IGR_Text_Compare_Document_Source doc1_source = { sizeof(IGR_Text_Compare_Document_Source) };
        IGR_Text_Compare_Document_Source doc2_source = { sizeof(IGR_Text_Compare_Document_Source) };
        IGR_Compare_Documents_Difference diff = { sizeof(IGR_Compare_Documents_Difference) };

        doc1_source.doc_handle = doc1;
        doc1_source.doc_first_page = 0;

        doc2_source.doc_handle = doc2;
        doc2.doc_first_page = 0;

        if ((ret = IGR_Text_Compare_Documents(&doc1_source, &doc2_source, &settings, &compare, &ecb)) == IGR_OK)
        {
            while (IGR_Text_Compare_Next(compare, &diff, &ecb) == IGR_OK)
            {
                // ... work with diff object

                IGR_Text_Compare_Difference_Dispose(&diff, &ecb);
            }

            IGR_Text_Compare_Close(compare, &ecb);
        }
    }

    if (doc1_handle)
        IGR_Close_File(doc1_handle, &ecb);
    if (doc2_handle)
        IGR_Close_File(doc2_handle, &ecb);

    return 0;
}

See Also