Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why SCAN does not EXIT?
Message
De
15/08/2002 14:24:55
 
Information générale
Forum:
Visual FoxPro
Catégorie:
The Mere Mortals Framework
Divers
Thread ID:
00689830
Message ID:
00690094
Vues:
21
Dennis,

>LOOPs and EXITs do not make any sense in SCANs or DO WHILEs, unless they are inside of a IF...ENDIF.<

Exactly! That's one of the points that I meant to make, but I guess I didn't. <g>

~~Bonnie



>Bonnie
>
>That is what I thought too, but it does not work that way all of the time. So, I have gotten into the habit of adding a SELECT at the end of my SCAN's if I SELECT another table in the middle of the SCAN.
>
>According to VFP help: LOOP, Returns control directly back to SCAN. LOOP can be placed anywhere between SCAN and ENDSCAN.
>
>If you remove the LOOP, you need to remove the EXIT too. Otherwise, the SCAN will exit after the first record. LOOPs and EXITs do not make any sense in SCANs or DO WHILEs, unless they are inside of a IF...ENDIF.
>
>>Dennis (and Ulises),
>>
>>>I have had a similar problem. Add "SELECT TABLE1" just before "LOOP".<
>>
>>Well, that *may* solve that problem, but only because of the LOOP. You don't need a LOOP inside of a SCAN/ENDSCAN and in fact, I doubt if it will work correctly (that's most likely what the original problem was). In a SCAN/ENDSCAN, if you have selected another table somewhere in the code, when VFP hits the ENDSCAN to "go around again", it automatically selects the "driving" table. There is no need to do it in code.
>>
>>~~Bonnie
>>
>>
>>>I have had a similar problem. Add "SELECT TABLE1" just before "LOOP".
>>>
>>>>Hi all.
>>>>I have a few lines of code like this:
>>>>SELECT TABLE1
>>>>GO TOP
>>>>xCOUNT=0
>>>>SCAN FOR OWE <> 0
>>>>STORE idSTD TO xidSTD
>>>>SELECT TABLE2
>>>>LOCATE FOR idSTD=xidSTD
>>>>REPLACE OWE WITH TABLE1.OWE
>>>>xCOUNT=xCOUNT+1
>>>>LOOP
>>>>EXIT
>>>>ENDSCAN
>>>>
>>>>Problem is it keeps going into an endless loop, without exiting when the last match is found. What am I missing?
>>>>
>>>>TIA
>>>>Ulises
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform