Subject |
Re: Wait Window Nowait |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Thu, 18 Jun 2020 14:50:30 +0200 |
Newsgroups |
dbase.getting-started |
Attachment(s) |
showprog.prg |
On 18/06/2020 12:35, Andy Taylor wrote:
> You can, however, easily build your own function within dBASE.
> The attached file will create a small table and a popup form which is all you need to see the calls shown below working:
> I have also deliberately used XML style commands to provide a familiar style.
>
> // Do the table scan
> use tempData
> showProg("Open")
> scan
> showProg()
> sleep(0.1) && will take 10 seconds to complete (we have 100 records)
> endscan
> showProg("Close")
> use
Nice idea.
To take this one step further, if the function and the code for the form
are taken out of progress.prg and saved in a .prg file with the same
name as the function i.e showprog.prg in the same folder as the main
program, then the original code can be written as
use whatever
showProg("Open")
do while not eof()
showProg()
// main stuff...
skip
enddo
showProg("Close")
clear window
use
Mervyn.
| function showProg(cMode)
// uses data from the current work area
do case
case cMode="Open"
// create a progress message form and attach it to a public
// variable which will keep it alive after the function call ends
public w; w = new Progform()
w.total = ltrim(str(reccount()))
w.Count = 0
w.open()
case cMode="Close"
// close the form and release the public variable
w.close()
release w
otherwise
w.count += 1
w.Msg.Text = "Record Count: "+ltrim(str(w.count))+" of "+w.total
_app.executeMessages() && ensure text update (probably overkill)
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
|
|