Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to NOT stop the Select SQL?
Message
 
 
To
27/01/2005 09:46:19
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
00980904
Message ID:
00981189
Views:
30
Hi Gregory,

I was able to solve this problem, though this is not 100% desired solution, but it is better than nothing. Basically, if I interrupted requery and answered I do not want to stop, I would prefer to continue, but the only way is to do a requery again.

Here is my solution:

I added a property called lRepeatRequery to my business object. In its Error method I put:
LPARAMETERS tnError, tcMethod, tnLine, tcSys16, toerrobj, tcMessage
IF m.tnError = 1839 && SQL-Select was cancelled	
   
	IF VARTYPE(m.plStop) = "L" AND m.plStop 
		* Have we stopped already?
	ELSE
		* RETRY  - doesn't work
		this.lRepeatRequery = .t.
	ENDIF
ELSE
	DODEFAULT(tnError, tcMethod, tnLine, tcSys16, toErrobj, tcMessage)
ENDIF
In its PopulateCursor method I put:
LOCAL lnRequeryResult 
	lnRequeryResult = .REQUERY() && requeries the initially selected alias
    
    IF .lRepeatRequery = .t. and m.lnRequeryResult < 0 && the user tried to stop it 
       .requery()       
    ENDIF
plStop is defined as private in the form's Search method (so it is visible to other objects) and on escape plStop = YesNo("Do you want to stop the process?")

Of course, it would not really work if the user will press ESC on the second requery and says "No" again, but it should be some real jerk to try that combination :)

>>Hi everybody,
>>
>>I want to be able to stop or not stop query execution if the user pressed an ESC while running query.
>>
>>First of all, I found that the documentation on Error 1839 is very limited and incorrect.
>>
>>Here is what I have in my Search button:
>>
>>SET ESCAPE ON
>>		SET NOTIFY ON
>>		ON ESCAPE plStop = YesNo("Are you sure you want to stop?")
>>		SET TALK WINDOW NOWINDOW
>>		SET TALK ON
>>		.nRecords = EVALUATE('thisform.obizObj.PopulateCursor('+ ;
>>			.cParams +')')
>>
>>and this is the code from Error method:
>>
>>LPARAMETERS nError, cMethod, nLine, tcSys16, toErrObj
>>IF m.nError = 1839 && Requery cancelled	
>>
>>	IF VARTYPE(m.plStop) = "L" AND m.plStop
>>		* Have we stopped already?
>>	ELSE
>>		RETRY
>>	ENDIF
>>ELSE
>>	DODEFAULT(nError, cMethod, nLine, tcSys16, toErrObj)
>>ENDIF
>>
>>However, if I say No, I don't want to stop, my view is not required (?spell) again. Is there a way to achieve the desired functionality? I do not see a way.
>>
>>Thanks in advance.
>__________________________________
>hi Nadya,
>
>I'll be following the thread closely.
>I basically tried the same a couple of weeks ago and I failed
>
>The intent was to let the user interrupt a long process. During that process some requery()s might occur
>
>
>on escape do abc
>
>
>func abc()
>     Escaped = TRUE
>     retry             && I added this one since I got the error during the requery
>endfunc
>
>
>and in a loop I checked Escaped once a second
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform