Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recursive loop and SCAN
Message
De
27/07/2002 00:11:17
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
26/07/2002 22:51:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00683191
Message ID:
00683207
Vues:
41
>>The SCAN/ENDSCAN only restores proper alias. It doesn't restore record pointer. I don't know what you're doing but maybe you can use USE ... AGAIN instead of using the same cursor. This way cursor became "local".
>
>This would be a nice enhancement in the SCAN command.

It could also break some code relying on Scan NOT restoring the record pointer.

>As for what I am trying to do, here's the Recursive() method:
>
>
>PARAMETERS tnNumero
>LOCAL lnRecno
>SCAN FOR NoParent=tnNumero
>   ...
>   lnRecno=RECNO()
>   This.Recursive(Numero)
>   GO lnRecno
>ENDSCAN
>
>
>So, as you can see, the method is calling itself. The only way I have succeeded to make it work, is by saving my pointer and restoring it back.

This is the way it worked ever since Scan was introduced. Alternately, you could do what Sergey meant:

>
>PARAMETERS tnNumero
>LOCAL lnRecno, lnWA
lnWA=select()
select 0
use (original alias here) again alias ("cur"+tran(tnumero))

>SCAN FOR NoParent=tnNumero
>   ...
>   This.Recursive(Numero)
>ENDSCAN
use in ("cur"+tran(tnumero))
select (lnWA)
>
So you have a new alias and a new record pointer for it in each level of recursion. And separate buffers for each, as a side effect.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform