|
|
|
|
| Find duplicate field values in selection |
Submitted by Keith Culotta, Computer Dimensions, Inc.
Here's a fairly fast 4D method for finding duplicates in a single field. Pass a pointer to the field. There must be enough memory to handle an array for each record's field value, a longint array of the selection's size and another longint array of up to half the selection's size.
The method can return a set of records that have a duplicate in the selection or just display a selection of the duplicates it found.
C_POINTER($1;$field;$table) C_TEXT($2;$DupSet) C_LONGINT($i;$size) C_LONGINT($0) C_BOOLEAN($addFirst;$sortArray)
$field:=$1 If ($2#"") $DupSet:=$2 Else $DupSet:="$DupSet" End if $sortArray:=$3
ARRAY LONGINT($aFound;0) ARRAY LONGINT($aRecs;0) $table:=Table(Table($field)) SELECTION TO ARRAY($table->;$aRecs;$field->;$afield)
If ($sortArray) SORT ARRAY($afield;$aRecs) End if
$size:=Size of array($aRecs) $addFirst:=True
For ($i;2;$size) If ($aField{$i}=$aField{$i-1}) If ($addFirst) APPEND TO ARRAY($aFound;$aRecs{$i-1}) End if APPEND TO ARRAY($aFound;$aRecs{$i}) $addFirst:=False Else $addFirst:=True End if End for
CREATE SET FROM ARRAY($table->;$aFound;$DupSet) $0:=Records in set($DupSet)
If ($2="") USE SET($DupSet) CLEAR SET($DupSet) End if |
|
Submit a Tip Archive  |
|
|
 |
|
|
|
| ObjectTools |
ObjectTools, developed by Aparajita's World, is a plug-in that gives you a full suite of commands for managing an object. An object is like a BLOB, but instead of accessing the data by offset, you access each data item by name. |
|
Suggest a Spotlight
|
|
|
 |
|
|
|
Today, we asked you...
|
| What model iPhone do you have? |
|
Your vote: (no vote)
Total votes received: 35
|
|
Suggest a Survey
|
|
|
 |
|