Tech Tip: Counting the total number of repeated elements in an array
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: February 7, 2003
Versions: 6.7 and 6.8
Here is a simple method that will count the total number of repeated elements in an array.
` Project Method: RepeatedArrayElement
`
` $1 - Pointer to an array
` $2 - Pointer to a variable that holds a Value of same
` type to search in the array
C_POINTER($1;$2)
C_BOOLEAN($Done)
C_LONGINT($next;$count)
$Done:=False
$next:=1
$count:=0
Repeat
$next:=Find in array($1->;$2->;$next)
If ($next>0)
$count:=$count+1
$next:=$next+1
Else
$Done:=True
End if
Until ($Done)
$0:=$count
A call to that method would look like this:
$result:=RepeatedArrayElement (->arrName;->varName)