#DEFINE clVFP9 version( 5 ) >= 900 if clVFP9 * 25/mar/2012 pdv * As long as no key is pressed, inkey() does not cause any error in Unattended Mode. * However, as soon as a key is pressed, it appears to cause error 2031 'User-interface * operation not allowed at this time'. * In my opinion this is a VFP design flaw. * Anyway, let's use that error to circumvent it. TRY lnKey = inkey() CATCH UnattendedServerMode( .F. ) lnKey = inkey() UnattendedServerMode( .T. ) ENDTRY else lnKey = inkey() endif
* Without parameter : Returns the current mode (true/false). * With parameter (.t./.f.) : Sets the mode and returns the mode after the change. * Not available in vfp7, and some modes (esp. devmode). FUNCTION UnattendedServerMode( tlON ) do case case not clVFP9 RETURN .F. case not inlist( _vfp.startmode, 2, 4 ) RETURN .F. case pcount() = 0 case m.tlON sys( 2335, 0 ) case not m.tlON sys( 2335, 1 ) endcase RETURN sys( 2335 ) == "0" && return TRUE if it is unattended server mode