4D Net Center Hosting
Home Directory Classifieds Reference Archives
Site Info
About 4DToday.com
Contact Us
Version française
Developers (723)
4D Developers (592)
Web Developers (335)
Tools Publishers (201)
Instructors (166)
Web Hosts (58)
Resellers (90)
Software Publishers (303)
Search Developers
Products (383)
Plug-Ins (104)
Components (48)
Code Libraries (9)
Books (7)
Tools (42)
Vertical Applications (148)
Search Products
User Groups
All User Groups (22)
Classified Ads (13)
Help Wanted (7)
Opportunities Wanted (6)
Hardware Wanted (0)
Hardware for Sale (0)
Software Wanted (0)
Software for Sale (0)
Other (0)
4D, Inc.
4D International
4D Wiki
4D Partner Central
4D Beginner's Center
4D Online Documentation
4D 2004 Example Applications
4D Example Databases
4D BugDisplayer
4D, Inc. Training
Message Lists
4D Mailing Lists
4D Tech Google Group
iNUG Archives (Nabble)
iNUG Archives (Gmane)
iNUG Message Index
4D Code Exchange
4D Resources
Sviluppo4D.it (Italy)
4D Sources (4D Plugin API, 4D Pop & Miyako
At bottom, every man knows perfectly well that he is a unique being, only once on this earth; and by no extraordinary chance will such a marvelously picturesque piece of diversity in unity as he is, ever be put together a second time.
Friedrich Nietzsche  
  Suggest a Quote  
hmCal 5.2 available for 4D v13 and v14
hmCal is a plug-in developed by heubach media, Hamburg, Germany for 4th Dimension.  hmCal 5.2 is a free maintenance update for all hmCal 5 users.  Would you like to know more? Wednesday
 Submit Future News    Archive 
Technical Tip
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.

// ----------------------------------------------------
// User name (OS): Keith
// Date and time: 11/16/12, 11:12:14
// ----------------------------------------------------
// Method: DuplicatesToSet
//          Search the current selection for duplicate values in a field.
// INPUT1: Pointer - to field to examine
// INPUT2: Text - name of Set to contain duplicates or ""
//          The selection will not be changed when a non blank string is passed.
//          In this case the calling method will handle the created Set.
//          Pass an empty string to make this method change the selection
//          to show any duplicates found.
// INPUT3: Boolean - Sort the array
//          Falsecan be passed if the selection is already sorted on $1
// OUTPUT: Longint - Number of records in the set
// ----------------------------------------------------


If ($2#"")
End if

SELECTION TO ARRAY($table->;$aRecs;$field->;$afield)

If ($sortArray)
SORT ARRAY($afield;$aRecs)
End if

$size:=Size of array($aRecs)
$addFirst:=True // add a record to the duplicate array only once

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})
End if
End for

CREATE SET FROM ARRAY($table->;$aFound;$DupSet)
$0:=Records in set($DupSet)

If ($2="")
USE SET($DupSet)
End if
  Submit a Tip    Archive 
TeamViewer TeamViewer - the All-In-One Software for Remote Support and Online Meetings
Remote control any computer or Mac over the internet within seconds or use TeamViewer for online meetings. Find out why more than 200 million users trust TeamViewer!
  Suggest a Spotlight  
Survey Results
This weekend, we asked you...
Have you used 4D Server, any version, successfully on any version of Mac OS X Server?
Survey Results

Your vote: (no vote)
Total votes received: 33

Survey submitted by Bill Weale
  Suggest a Survey  
There are no events scheduled for the upcoming fortnight.
  Submit an Event