Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need efficient algorithm - urgent!
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Need efficient algorithm - urgent!
Divers
Thread ID:
00695565
Message ID:
00695565
Vues:
52
Hi everybody,

Ok, my brain doesn't work right now with its usual efficiency, so I'm asking for help.

I have a table with duplicate records (I already marked duplicate with Flag='D'). The table has CD1, CD2, CD3, CD4, CD5, CD6 fields. The goal is: eliminate duplicates for Ass1=0 (record with Ass1<>0 should be left) and combine CD1, CD2, etc. for this one record left. These fields should be sorted, e.g. here is an example
Map15    CD1    CD2     CD3   CD4    CD5   CD6    Ass1
9        34      36                                78738  
9        10      12      22                         0
9        22      25                                 0

------------ 

Desired result:
9       10      12      22     25     34   36     78738
Here is the algorithm, I started to write, but I can not finish:
********************************************************************
*  Description.......: Update_Cheshire - removes duplicates and does other manipulations 
*  Calling Samples...: 
*  Parameter List....: 
*  Created by........: Nadya Nosonovsky 08/30/2002 04:09:05 PM 
*  Modified by.......: 
********************************************************************
use cheshire in 0 alias Scan_File order map15
use cheshire in 0 alias Update_File again
local lcMap, lcLoc, lnAss1, lcCd1, ;
      lcCd2, lcCd3, lcCd4, lcCd5, lcCd6, ;
      lnRecno, lcString, llAllow, lnElements, lnI
local array laOriginal, laNew

lcMap=""
lcString = ""
lcLoc = ""
select Scan_File
scan for Flag='D'
    if Ass1<> 0
         lnRecno = recno()
     endif

   if Map15<>m.lcMap
      if m.llAllow
      goto m.lnRecno in Update_File
      replace CD1 with m.lcCD1, 
              CD2 with m.lcCD2, 
              CD3 with m.lcCD3, 
              CD4 with m.lcCD4, 
              CD5 with m.lcCD5,  
              CD6 with m.lcCD6 
      delete for recno()<>m.lnRecno and Map15 = m.lcMap and Ass1=0 in Update_File         
      endif
      lcMap = Map15
      lcString = iif(not empty(cd1),cd1+chr(13),"") + ;
                 iif(not empty(cd2),cd2+chr(13),"") + ;
                 iif(not empty(cd3),cd3+chr(13),"") + ;
                 iif(not empty(cd4),cd4+chr(13),"") + ;
                 iif(not empty(cd5),cd5+chr(13),"") + ;
                 iif(not empty(cd6),cd6,"") 
      lcLoc = Loc
    else
      if m.lcLoc<>Loc && Address is different, don't do replacements     
         llAllow = .f.
      else
         if not cd1 $ m.lcString or not cd2 $ m.lcString or not cd3 $ m.lcString or not cd4 $m.lcString
            lnElements = alines(laOriginal, m.lcString)
            =asort(laOriginal)
            dimension laNew[m.lnElements]
            for lnI=1 to m.lnElements
                if            
                 
  endif
Could you please help?

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform