CompareTextDiff

Mon 01 January 2018

Syntax

CompareTextDiff(new_text, old_text [, content_type [, delimiter]]) 

Description

Use the CompareTextDiff function to compare the content of new_text with the content of old_text and return an array of array of any detailing the differences between the two strings. The elements of the returned subarray are as follows:

Element

Data Type

Description

index

number

The sequential index number in the comparison array.

line

number

The line number for the line of text being compared.

subline

number

The subline is the counter of added lines that exist in the new_text.

Note: For DELETE, CHANGED and COMMON operations, 0 is always reported for the subline.

type

string

The type of difference:

  • COMMON – Both lines are the same

  • ADD – A line is present in new_text that is not in old_text.

  • DELETE – A line is absent in new_text that is present in old_text.

  • CHANGED – A change in a line shows as an Add in new_text and a Delete in old_text.

text

string

The actual text being compared.

Parameters

Field or Control

Definition

new_text

Specifies the string that you want to compare with the old version of the string.

old_text

Specifies the old version of the string for comparison.

content_type

Specifies the content type as a literal: text or html. This parameter is optional.

If content_type is html, HTML tags are stripped and are not included in the comparison.

If content_type is not specified, it is set by default to text.

delimiter

An array of string specifying the delimiters to be used to split the content for comparison. This parameter is optional.

If content_type is text and delimiter is not specified, the delimiter is set by default to char(13) (or \n, a carriage return).

If content_type is html and delimiter is not specified, the delimiter array is populated by default with the following values:

["</p>", "</br>", "</h1>", "</h2>", "</h3>", "</h4>", ⇒
"</h5>", "</h6>", "</div>", "</address>", "</pre>", ⇒
"</br>", "</tr>", "</caption>", "</blockquote>"]

Returns

An array of array of any.