Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The Great ESC?
Message
De
24/04/1999 10:57:37
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00209813
Message ID:
00211878
Vues:
36
>>>>I have a program running in a continous loop on purpose. I want a button on my form to act almost like "Pressing the ESC key" to interrupt the program that's in the continuous loop.
>>>>
>>>>Is there a way to do it without getting the VFP error dialog box that says, "Cancel, Suspend, Ignore, etc." when you press the ESC key?
>>>>
>>>>I guess I can use the CHR() with ESC character code to cause the interrupt to occur, but I don't want the VFP error that follows. Can I trap the error before it is displayed and not show it?
>>>>
>>>>Thanks for your help in The Great ESC.
>>>>
>>>>Your truly,
>>>>Steve "McQueen" Kramer
>>>
>>>Try this
>>>
>>>lIsRun = .T.
>>>DO WHILE lIsRun
>>> SCAN
>>> IF INKEY() = 27
>>> lIsRun = .F.
>>> ENDIF
>>>... my main code is here
>>> ENDSCAN
>>>ENDDO
>>>
>>
>>This has the same not-so-subtle bug as my example; if the table is empty, the INKEY() is never evaluated.. In addition, the scan continues to EOF if the Esc key is pressed, rather than aborting immediately.
>>
>>>Sincerely,
>
>Try modified version:
>
>lIsRun = .T.
>DO WHILE lIsRun

You'd need a GO TOP here, since the WHILE clause doesn't have SCAN move the pointer to the top - it assumes you're positioned properly and want to continue from the current record pointer position - which means that the second and subsequent passes will start at EOF.

> SCAN While lIsRun
> IF INKEY() = 27
> lIsRun = .F.
> ELSE
> ... my main code is here
> ENDIF
> ENDSCAN
> lIsRun = (Inkey()#27)
>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