how compare the array and remove the similar values, using Code unit.

how compare the array and remove the similar values, using Code unit.

for example

ArrayA[AB],
ArrayA[AB],
ArrayA[AB],
ArrayA[CD],
ArrayA[CD],
ArrayA[CD],

ArrayB[AB],
ArrayB[AB],
ArrayB[AB],
ArrayB[CD],
ArrayB[CD],
ArrayB[CD],

When compare ArrayA and ArrayB, how can i remove duplicates.

thanks

Hi Smnehal,

I’m not quite sure what you ask.

But if it’s a simple array you could do it like this.
Define a record-variable, that has a primary key that matches your array.
remember to define it as a temporary record variable.
Now you can loop through the array, and try to insert the array-value in the record-var.
If this is not a succes, it’s because the value already has been inserted (from another dimension in the array), and the actual dimension in the array can be cleared.

To my knowledge there is no way to simply compare 2 arrays.
(but i’m up for new knowledge if anyone knows better)

Quite simple procedure:

Variables:
txArr (TEXT(30) ARRAY of 11
i (Integer)
j (Integer)
x (Integer)

Code:
txArr[ 1] := ‘a’;
txArr[ 2] := ‘b’;
txArr[ 3] := ‘c’;
txArr[ 4] := ‘d’;
txArr[ 5] := ‘g’;
txArr[ 6] := ‘a’;
txArr[ 7] := ‘f’;
txArr[ 8] := ‘g’;
txArr[ 9] := ‘t’;
txArr[10] := ‘x’;
txArr[11] := ‘b’;

FOR i := 1 TO ARRAYLEN(txArr) - 1 DO
FOR j := i + 1 TO ARRAYLEN(txArr) DO BEGIN
IF txArr[i] = txArr[j] THEN
txArr[j] := ‘’;
END;

x := COMPRESSARRAY(txArr); //x is the number of non-empty elements