Newsgroups: comp.databases
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!news.UVic.CA!csr!msholind
From: msholind@csr (Murray Sholinder)
Subject: Re: CLIPPER array dups problem
Message-ID: <1991Apr25.073428.6456@sol.UVic.CA>
Sender: news@sol.UVic.CA
Nntp-Posting-Host: csr.uvic.ca
Organization: University of Victoria, Victoria B.C. CANADA
References: <22963@gremlin.nrtc.northrop.com>
Distribution: usa
Date: Thu, 25 Apr 91 07:34:28 GMT

In article <22963@gremlin.nrtc.northrop.com> maurit@nrtc.nrtc.northrop.com (Mark Aurit <maurit>) writes:
>In a program I take the contents of an ascii file, read it into a
>.dbf and manipulate it, then present it to the user with
>achoice(). Unfortunately, the ascii file contains dups, and I
>dont want my picklist to have any. What is the best way to remove
>them? Where is the best place - in the .dbf or in
>the array. Ascan() and adel() dont seem to do the trick. I guess I
>could try a locate/continue; Im wondering if anyone has a slick (but
>maintainable!) idea.
>
>On input, the ascii file might look like:
>   4
>   buffed.dbf
>   trick.dbf
>   stormin.dbf
>   norman.dbf
>I APPEND it into a database, delete the first line, pack the file, read
>it into an array, then achoice() it.

One solution to your problem would be to append the ASCII file into a 
database, delete the first line, pack the db, THEN create a UNIQUE index 
of the db on the field where the duplicates occur. 

    eg. INDEX ON dbname TO namendx UNIQUE

By indexing the db with UNIQUE on and then accessing your db with the 
index active, the duplicates will no longer be visible. This way you won't 
have to spend the time skimming through the db to find dups, mark them for 
deletion, and then pack the db. If it is absolutely necessary to remove the 
dups, you could use the above procedure and then append the indexed db 
to a similarly structured db, which would then only contain unique names 
without the need of an index.

I hope this helps.

Murray Sholinder
Sholinder Computing
Victoria, BC 
