often times i need to break out from a loop if user hit the escape key. in order to do that, will have to:
- save the existing state of the set escape
- set up on escape
- restore set escape afterward
to those not familiar with vfp commands and how vfp does things, it may be difficult to figure this logic out. i have encapulated all this into a class to make it easier to understand what is happening.
loesctoabort = createobject('syesctoabort')
for i = 1 to infinity
the class is:
define class syesctoabort as relation
icoldescape = ""
ilescapehit = sys(2015)
this.icoldescape = set("escape")
set escape on
execscript([on escape ] + this.ilescapehit + [ = .t.])
lcoldescape = this.icoldescape
set escape &lcoldescape
llaborted = evaluate(this.ilescapehit)
execscript(this.ilescapehit + [ = .f.])
- the class creates a global variable during its lifetime.
- the original on escape command is not preserved.