Friday, August 08, 2008
You Are Here:
Blogs
Register
|
Login
Home
Projects
Clients
Software
Blogs
Login
User Name:
Password:
Remember Login
Forgot Password ?
List
View All Recent Entries
FoxPro / Visual FoxPro tips, tricks and traps.
Coming back to FoxPro after a long absence...
Host for the
Toronto Ontario FoxPro User's Group
Fox Ridge Software Inc. - The best in custom business software.
OOP VFP SQL Progress Bar
Location:
Blogs
FoxPro / Visual FoxPro tips, tricks and traps.
Posted by:
myearwood
12/19/2005
You've probably seen code to SET TALK ON before running your query to show the SQL thermometer/progress bar. First off, all such techniques require you to write several statements before and after the SQL. In a procedural approach you'd have to either build a single routine where you pass in the SQL command for execution OR you'd have to run a preSQL and postSQL pair of routines.
OOP makes the best solution. Have an object prepare the environment for the query during it's init. You then run your query and release the object where it restores the environment in it's destroy.
You'd use it like this...
LOCAL m.loThermo
m.loThermo = NEWOBJECT("cusSQLThermo","cusSQLThermo.VCX")
SELECT SOMEFIELDS FROM SOMETABLE WHERE SOMECONDITION
RELEASE m.loThermo
That's pretty simple. It's made possible by this little class:
**************************************************
*-- Class: cussqlthermo (cussqlthermo.vcx)
*-- ParentClass: custom
*-- BaseClass: custom
*-- Time Stamp: 10/18/05 09:07:11 PM
*
DEFINE CLASS cussqlthermo AS custom
*-- Holds SET TALK setting at initialization.
PROTECTED icoldsettalk
icoldsettalk = ""
*-- Holds SET NOTIFY setting at initialization.
icoldsetnotify = ""
*-- Holds the output window at initialization.
PROTECTED icoldoutputwindow
icoldoutputwindow = ""
*-- Holds the name of the temporary output window.
PROTECTED icnewoutputwindow
icnewoutputwindow = ""
Name = "cussqlthermo"
PROCEDURE Destroy
SET TALK OFF
LOCAL ;
m.lcNewOutputWindow, ;
m.lcOldOutputWindow, ;
m.lcOldSetNotify, ;
m.lcOldSetTalk
WITH THIS
m.lcNewOutputWindow = .icNewOutputWindow
m.lcOldOutputWindow = .icOldOutputWindow
m.lcOldSetNotify = .icOldSetNotify
m.lcOldSetTalk = .icOldSetTalk
ENDWITH
IF VERSION(5)>=700
SET NOTIFY &lcOldSetNotify.
ENDIF
SET TALK &lcOldOutputWindow.
RELEASE WINDOWS &lcNewOutputWindow.
SET TALK &lcOldSetTalk.
ENDPROC
PROCEDURE Init
*Class that activates SQL thermometer bar during init
*and restores altered settings during destroy.
WITH THIS
.icOldSetTalk = SET("TALK")
SET TALK OFF
.icOldOutputWindow = SET("TALK",1)
.icNewOutputWindow = "SQLThermo"+SYS(2015)
LOCAL m.lcNewOutputWindow
m.lcNewOutputWindow = .icNewOutputWindow
DEFINE WINDOW &lcNewOutputWindow. FROM -1000,-1000 TO -500,-500
ACTIVATE WINDOW &lcNewOutputWindow. IN SCREEN
SET TALK WINDOW &lcNewOutputWindow.
IF VERSION(5)>=700
.icOldSetNotify = SET("NOTIFY")
SET NOTIFY ON
ENDIF
ENDWITH
SET TALK ON
RETURN .T.
ENDPROC
ENDDEFINE
*
*-- EndDefine: cussqlthermo
**************************************************
Copyright ©2005 Fox Ridge Software
Permalink
|
Trackback
Comments (0)
All Blogs
FoxPro / Visual FoxPro tips, tricks and traps.
Coming back to FoxPro after a long absence...
Keywords
Phrase
Archive
<
August 2008
>
Sun
Mon
Tue
Wed
Thu
Fri
Sat
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
Monthly
April, 2006
December, 2005
Copyright 2005-2009 by Fox Ridge Software, Inc.
Privacy Statement
Terms Of Use