Function SetCancel() Foundation

Sets or returns whether the program can be terminated using Alt+C or Ctrl+Break.

Syntax
SetCancel( [<lToggle>] ) --> lOldSetCancel
Parameters
<lToggle>
The logical expression <lToggle> determines whether a program can be terminated at runtime by the key combination Alt+C. When the value of <lToggle> is .T. (true), this key combination terminates the application, otherwise it does not. By default an Xbase++ application can be terminated with Alt+C.
Return

When SetCancel() is called without an argument, the function returns the current setting as a logical value. If <lToggle> is specified, the new setting specified by <lToggle> is set, and the value of the old setting is returned.

Description

The environment function SetCancel() sets or removes the key combination Alt+C as a method to terminate a program. In the production version of applications, the Alt+C key combination should generally be disabled as a method to terminate the application, in order to force the user to leave the application by normal means.

Examples
SetCancel()
// The example shows a typical use of SetCancel(). When the 
// #define constant DEBUG is set, the program can be terminated 
// with Alt+C. When the constant is not defined (as is done for 
// the final production version), the program can no longer be 
// terminated with Alt+C. 

#include "Inkey.ch" 

PROCEDURE Main 
   LOCAL nKey := 0 

   #ifndef DEBUG                     // no debug version 
      SetCancel(.F.)                 // turn off Alt+C 
   #endif 

   DO WHILE nKey <> K_ESC 
      nKey := Inkey(0) 
      ? "The inkey code of the last key is:", nKey 
   ENDDO 

RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.