Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Major Index bogdown! HELP!
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00177210
Message ID:
00177277
Vues:
33
Mark,

It's kind of hard to read exactly what you are trying to do in that code. You basically have an O(n2) algorithm there. And (1.5x10^6)2 is quite a bit bigger than (5x10^5)2. And it may be even worse then O(n2) depending on how the other two fields end up inside your looping structure.

The GO TOP is not rushmore optimizeable you should use a LOCATE instead. Changing ORDER etc might be better handled by using the same table under alternate aliases. There may even be a couple of SQL statements that can handle the operation.

Can you describe in words what your loop is doing? Maybe show a couple of records before and after processing?

>We use a SEEK, followed by a DO WHILE loop. Here's a psuedo-code description:
>
>SET ORDER TO nGroup
>
>DO WHILE nGroup = 0
> liRecno = RECNO()
> lcField1 = cField1
> SET ORDER TO cField1
> SEEK lcField1
> DO WHILE cField1 = lcField1
>  IF (RECNO() <> liRecno) .AND. (nGroup > 0)
>   *- This is a matching record, other than the one we're using..
>   lnGroup = nGroup   && Get the group ID from this one...
>   GO liRecno
>   REPLACE nGroup WITH lnGroup
>   EXIT
>  ENDIF
> ENDDO
>
> IF nGroup = 0
>  *- No match, just create a new group ID here...
> ENDIF
>
> SET ORDER TO nGroup
> GO TOP   && Go to the next un-matched record...
>ENDDO
>
>It basically assigns the current record to a record that matches on one field. There are actually 3 fields used to match by, I left them out for clarity.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform