Subject Re: How to flash a message without waiting
From Mervyn Bick <invalid@invalid.invalid>
Date Tue, 24 Aug 2021 16:04:10 +0200
Newsgroups dbase.getting-started
Attachment(s) SHOWPROGRESS.prgtest_showprogress.prg

On 2021/08/24 13:27, Milind Nighojkar wrote:
> Scenerio.
> I hv a code which takes several minutes to process.
> 1.How to flash a message without waiting while program is still executing

For short processes I use the beginwait() and endwait() methods in
cursor.cc in the dUFLP.

For longer processes, if I have a form open I add a progress bar.

For a program I use showprogress.prg  which opens a small form on the
screen.  The program and a test program are attached.


> 2. what is the syntax for closing a form in a program

It depends how the form was created and opened.  If an instance of the
form was saved in a variable then simply variableName.close()

If the form was opened using  DO form.wfm   then you can use
findinstance()  There is example code in the help files.

Mervyn.





function showProgress(cMode)

   //Pass progress message to oProgress.msg.text
  
      _app.allowYldOnMsg = true
   do case
      case cMode="Open"
         // Create a progress message form and attach it to a public variable
         //Using a public variable ensures that the form stays available and
         //doesn't "die" when the program ends..
         public oProgress
         oProgress = new Progform()
         oProgress.open()
      case cMode="Close"
         oProgress.close()
         release oProgress
    endcase      
   return
  
class ProgForm of FORM
   with (this)
      metric = 6        // Pixels
      text = "Progress"
      autoSize = true
      autoCenter = true
   endwith
   this.MSG = new TEXTLABEL(this)
   with (this.MSG)
      height = 24.0
      left = 0.0
      top = 0.0
      width = 280.0
      text = ""
      borderStyle = 4        // Single
      alignVertical = 1        // Middle
   endwith
endclass


d = new database()
d.databasename = "dbasesamples"
d.active = true
q = new query()
q.database = d
q.sql = 'select * from customers'
q.active = true
showprogress("Open")
n = 0
do while not q.rowset.endofset
   q.rowset.next()
   n++
   cN = '  '+n+ '  records processed'
   oProgress.msg.text = cN
   inkey(0.2)
enddo
showprogress("Close")
q.active = false
d.active = false