distinct_field

Generates a list with a single field of distinct values.

Syntax

list distinct_field(list-name,col-index)
list                list-name
expr                col-index

Description

Returns a list with a single column of distinct values.

list-name

identifies the name of the list that contains the field to be made distinct.

col-index

identifies the sequence number of the field to be made distinct.

This function sorts the source list on a specified field to group duplicate values. Distinct values in the specified field are read to a second list which is returned.

Example

Chemists often save and retrieve hit lists of structures. distinct_field() can be used to make a user's hit list of distinct structure numbers. Later, this list can be opened and formatted into a SQL 'in' predicate to retrieve data on the structures.

 {
 list distinct_list;
 distinct_list= distinct_field(wl,0);/* pass name of wl and */
           /* seq of structure field*/
 G.fname= filename("");              /* prompt user for filename        */
 if (G.fname)                        /* user entered fname & not cancel */
   list_save(distinct_list,G.user_dir,"an");/*parms=list,path, */
           /*suffix       */
 distinct_list=NULL;
 }


Updated 19 May 1999. Copyright DataAspects Corp. 1998-1999