Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The Great ESC?
Message
De
22/04/1999 16:45:16
 
 
À
22/04/1999 16:37:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00209813
Message ID:
00211308
Vues:
44
>>David,
>>
>>I tried your suggestion for breaking out of an infinite loop. I must still be doing something wrong. Can you see anything wrong with this picture?
>>
>>I took one button on my form and named it cmdCloseWindow and set its Cancel property to .T. as you suggested. You mentioned that pressing the button would return a 27 which looks like an ESC key to me. But I believe I also SET ESCAPE OFF in the form Load procedure. Any ideas why it's not working to break out of the loop? That's all that is wrong with my form. Here's my code:
>>
>>DO WHILE .T.
>> SCAN
>> DOEVENTS()
>> IF LASTKEY() = 27
>> EXIT
>> ENDIF
>>... my main code is here
>> ENDSCAN
>
>You need TWO exits - one from the SCAN, and one from the DO WHILE, or you need a way to terminate the DO WHILE, like:
>
>
lExit = .F.
>DO WHILE ! lExit
>   GO TOP
>   SCAN WHILE ! lExit
>      * do what you want
>      DOEVENTS()
>      lExit = (LASTKEY() = 27)
>   ENDSCAN
>ENDDO
>
BTW, there's a semi-subtle bug here - you'll never be able to exit with the code above unless there's at least one record in the table; if the table is empty, the code within the SCAN loop never executes. So checking LASTKEY() outside the SCAN is also needed...

>>ENDDO
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform