Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: FoxPro FAQ

SQL Syntax

OOP way to get a SQL progress bar. by myearwood
Posted: 18 Oct 05

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")


RELEASE m.loThermo

That's pretty simple. It's made possible by this little class:


*-- Class:        cussqlthermo (c:\vmp2005\my\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 lcNewOutputWindow, lcOldOutputWindow, lcOldSetNotify, lcOldSetTalk
        lcNewOutputWindow = THIS.icNewOutputWindow
        lcOldOutputWindow = THIS.icOldOutputWindow
        lcOldSetNotify = THIS.icOldSetNotify
        lcOldSetTalk = THIS.icOldSetTalk

        IF VERSION(5)>=800
          SET NOTIFY &lcOldSetNotify.

        SET TALK &lcOldOutputWindow.

        RELEASE WINDOWS &lcNewOutputWindow.

        SET TALK &lcOldSetTalk.

        *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

        SET TALK ON

        RETURN .T.

*-- EndDefine: cussqlthermo

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close