Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SET ESCAPE OFF - Best way to stop user interrupting prog
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00794411
Message ID:
00794437
Vues:
20
>When in a Form and running some code that could take a few minutes, users can interrupt the process by pressing the ESC key. Is the best way to prevent this using:
>SET ESCAPE OFF

Yes. However, if you want a mechanism to allow the user to interrupt the process the routine ESCInBuf() offers a way to handle that.
set escape off
scan while not Escaped()
   <some job>
endscan
set escape on
RETURN

FUNCTION Escaped
   if ESCInBuf() and messagebox( 'Abort?', 1+32 ) = 1
      RETURN .T.
   endif
   RETURN .F.

*	Author............: PDV
*	Created...........: 28/feb/2000
*	Copyright.........: PDV 1996
*	Description.......: Function checks whether there is an ESC code in the keyboard buffer.
*                           Nice feature of FoxPro: The asciicode 27 is always at the front of the buffer.                     .
*	Calling Samples...: if ESCinBuf()
*	Parameter List....:	
*		            tlKeepbuf  Specify True if you want to preserve the buffer (incl. esc-codes).
FUNCTION ESCinBuf
	lparameters tlKeepbuf
	local lcInbuf, lnThiskey, llFound

	llFound = .f.

	do case
	case not chrsaw()
	case pcount() = 0 or not tlKeepbuf
		if inkey() = 27
			llFound = .t.
		endif
		clear typeahead
	otherwise
		lcInbuf = ''
		do while chrsaw()
			lnThiskey = inkey()
			if lnThiskey = 27
				llFound  = .t.
			endif
			lcInbuf = lcInbuf + chr( lnThiskey )
		enddo
		keyboard lcInbuf
	endcase

	RETURN (llFound)
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform