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)