Caché MultiValue Basic Reference
GTS

 Server:docs2 Instance:LATEST User:UnknownUser

 [ Home ]  >  [ MultiValue Features of Caché ]  >  [ Caché MultiValue Basic Reference ]  >  [ Caché MultiValue Basic Functions ]  >  [ GTS ] Go to: Description Examples See Also Search:

Performs a greater than comparison on elements of two dynamic arrays.
Synopsis
`GTS(dynarray1,dynarray2)`
Arguments
 dynarray An expression that resolves to a dynamic array.
Description
The GTS function compares each corresponding numeric element from two dynamic arrays and determines which value is greater. It returns a dynamic array of boolean values in which each element comparison is represented. It returns a 1 if the dynarray1 element value is greater than the dynarray2 element value. It returns a 0 if the dynarray1 element value is equal to or less than the dynarray2 element value.
GTS converts numbers to canonical form, resolving multiple signs and removing leading and trailing zeros from element values before making the comparison. If an element value is a missing element, a null string, or a non-numeric value, GTS assigns it a value of 0 for the purpose of this comparison.
If the two dynamic arrays have different numbers of elements, the returned dynamic array has the number of elements of the longer dynamic array. By default, the shorter dynamic array is padded with 0 value elements for the purpose of comparison. You can also use the REUSE function to define behavior when specifying two dynamic arrays with different numbers of elements.
For two elements to be compared, they must be on the same dynamic array level. For example, you cannot compare a value mark (@VM) dynamic array element to a subvalue mark (@SM) dynamic array element.
Examples
The following example uses the GTS function to return a greater than comparison for each of the elements in dynamic arrays a and b. It also performs a GES (greater than or equal) comparison on the same dynamic arrays:
```a=10:@VM:-22:@VM:-33:@VM:45
b=10:@VM:-23:@VM:0:@VM:44
PRINT GTS(a,b)
! returns 0ý1ý0ý1
PRINT GES(a,b)
! returns 1ý1ý0ý1```
The following example compares dynamic arrays of different lengths. Note that missing elements within the dynamic array (@VM:@VM) are compared, but unmatched elements from the longer array always return 1:
```a=11:@VM:21:@VM:30:@VM:@VM:51
b=10:@VM:@VM:30:@VM:40:@VM:50:@VM:60:@VM:70
PRINT GTS(a,b)
! returns 1ý1ý0ý0ý1ý1ý1
PRINT GTS(b,a)
! returns 0ý0ý1ý1ý0ý1ý1```