Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL escape function
Message
 
 
To
01/02/2000 13:28:54
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00325712
Message ID:
00325731
Views:
25
This message has been marked as the solution to the initial question of the thread.
>Hello,
>I'm working on a SQL in FoxPro 2.6, and I want to give the user the chance to escape from the long query with pressing the ESC button.
>What is the best way to do that?
>I would have a solution, but I'm not sure whether this is the best, and I wanted to hear some other ideas on this.
>Thanks for your time.

Cristian,

There is code below to do what you want
FUNCTION SQLframe
* Purpose : Set up the environment for executing SQL statement 
*				and  clean up after it is finished
*
* Parameters : 1 - "SET UP" - Saves settings and allows a user use 
*							the ESCAPE key to cancel following SQL-Select
* 						 "CLEAN UP" - Restore the pevious settigs
*					2 - A text of message to be displayed
*
* Return : For "SET UP" always .T. 
*			  For "Clean UP" - .F. if SQL-select was terminated by user (Escape key was pressed)	
*

PARAM action, msg

action = UPPER(CHRTRAN(IIF(EMPTY(m.action), "SET UP", m.action), " ", ""))

DO CASE
CASE INLIST(m.action, "SETUP", "ON")
	PUSH KEY
		
	m.msg = IIF( TYPE("m.msg") = "C", m.msg, ;
		" Processing Your Request. " + CHR(13) +;
		" Please Be Patient ...")
	IF NOT EMPTY(m.msg)
		WAIT CLEAR
		WAIT WINDOW NOWAIT m.msg
	ENDIF
		
	PUBLIC ARRAY gaSQLframe[7]
	gaSQLframe[1] = SYS(2015)			&& Window name
	gaSQLframe[2] = .F.					&& Was the escape key pressed during execution
	gaSQLframe[3] = ON("ESCAPE")		&& Save previous ON ESCAPE setting
	gaSQLframe[4] = SET("ESCAPE")		&& Save previous SET ESCAPE setting
	gaSQLframe[5] = SET("TALK")		&& Save previous SET TALK setting
	gaSQLframe[6] = SET("TALK", 1)	&& Save previous SET TALK setting

	SET TALK WINDOW
	SET TALK ON

	DEFINE WINDOW (gaSQLframe[1]) FROM 7,10 TO 16, 69 COLOR SCHEME 5 DOUBLE

	ACTI WIND (gaSQLframe[1]) NOSHOW
	@ 0,1 SAY 'Hit <Esc> to Cancel The Selection ...'
	ACTI WIND (gaSQLframe[1]) SAME

	SET ESCAPE ON
	ON ESCAPE gaSQLframe[2] = .T.
	
	RETURN
	
CASE INLIST(m.action, "CLEANUP", "OFF")

	ON ESCAPE  &gaSQLframe[3]
	SET ESCAPE &gaSQLframe[4]
	SET TALK   &gaSQLframe[5]
	SET TALK   &gaSQLframe[6]

	RELE WIND (gaSQLframe[1])

	POP KEY
	PRIVATE m.EscPress
	m.EscPress = gaSQLframe[2]
	RELEASE gaSQLframe
	WAIT CLEAR
	
	IF m.EscPress
		WAIT WIND TIME 2 "Canceling your request ...."
	ENDIF

	RETURN NOT m.EscPress
	
OTHER
	WAIT WIND "SQLFrame ERROR: Unknown action!"
	RETURN .F.
ENDCASE

RETURN
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform