Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing Duplicates in an Array?
Message
De
03/11/2001 07:19:50
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
02/11/2001 16:06:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00576991
Message ID:
00577106
Vues:
16
>>Any simple way to remove duplicates in a one dimensional array? No specific order to the rows and the elements are text. I'm thinking of looping through, and comparing elements, but the no-order thing has got me paused... Thanks!
>>
>>Regards, Renoir
>
>Renoir,
>
>I don't know how many items you have in the array, but my first thought is this:
>
>create table temp (cElement c(20))
>iterate through the elements and append to table
>select * from temp ;
> order by cElement ;
> group by cElement into cursor tempCursor
>create a newArray (or redimension old one, and reuse it)
>scan/endscan through tempCursor and put into new array
>
>Should work pretty quickly...

Steve,
Honestly cursor way being the first thought for me too I wanted to make a note here. After creating the cursor you don't need to iterate through elements to append, append from array or insert into myCursor from array myArray works (provided that first you make it 2 dimensional with one column first) :
dimension myArray[alen(myArray,1),1]
create cursor temp (cElement c(20))
append from myArray
* or
insert into temp from array myArray
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform