Array Compare

From MultiCharts
Revision as of 10:59, 4 March 2017 by Admin (talk | contribs)
Jump to navigation Jump to search

Compares a specified range of elements of the specified one-dimensional source array, starting at the specified source index, to the same range of elements of the specified one-dimensional destination array, starting at the specified destination index. Source and destination can be the same array as well as two different arrays.

For numerical arrays, the numerical values for each pair of elements are compared. For string arrays, the ASCII values of the string characters, with the first character of the string being the most significant, are compared for each pair of elements. For true/false arrays, the logical values of each pair of elements are compared, with the value of true considered to be greater than the value of false.

Returns a value of 0 if each respective pair of elements compared as equal; a value of 1 if, for the first pair that was not equal, the value in the source range was greater then the value in the destination range; and a value of -1 if, for the first pair that was not equal, the value in the source range was less then the value in the destination range.

Usage

Where:

SourceArray - an expression specifying the name of the source array
DestinationArray - an expression specifying the name of the destination array
SourceIndex - a numerical expression specifying the starting index for the source array
DestinationIndex - a numerical expression specifying the starting index for the destination array
NumberOfElements - a numerical expression specifying the number of elements to compare

Return

0 - each respective pair of elements compared as equal

1 - for the first pair compared that was not equal, the value in the source range was greater then the value in the destination range

-1 - for the first pair compared that was not equal, the value in the source range was less then the value in the destination range

Example

Assign a value, indicating the result of comparing two-element segments, of Array1, beginning at the index of 4, and of Array2, beginning at the index of 6, to Value1 variable:


Assign a value, indicating the result of comparing two-element segments that begin at the index of 4 and at the index of 6 within the same array, to Value1 variable: