| Subject |
Re: Wait Window Nowait |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Wed, 17 Jun 2020 16:35:36 +0200 |
| Newsgroups |
dbase.getting-started |
| Attachment(s) |
Ketan1.wfm |
On 17/06/2020 13:28, Ketan G wrote:
> Thanks Akshat,
> will have a look at that thread.
>
> Perhaps the original post should also be more clear.
>
> This is an xbase program looping through a file and
> the Wait Window Nowait command (in Foxpro) is used to display
> and update the record number so that the user knows
> that something is happening, without having to "press
> any key to continue" for each record.
>
> eg.
> do while not eof()
> wait 'Record Number: ' + ltrim(str(recno())) window nowait
> main stuff...
> skip
> enddo
> clear window
>
> A quick and ready way to get what is needed.
>
> Of course, the Progress Bar will have all this but
> is there something similar in dBase/duFLP?
dBASE has the WAIT command for use with XDLM (the original commands
before Objects were added to dBASE) but the command does not have the
NOWAIT switch. WAIT stops processing until the user presses a key. A
standard msgbox object will also not do the job as it halts processing
until the user acknowledges the message. The code Akshat referred to
from Bernard Mouille may do the job but I haven't had a chance to look
at it properly.
What you could do is replace the wait...nowait line with a simple print
statement. This will print the message in the Results panel. Each
message will print on a new line. If you use CLEAR after a given number
records you can keep the display a reasonable length. If your loop
takes a reasonable time to process each record the you can clear the
Result panel after every 2nd record. The messages will all appear in
the same place but will flicker badly. Messy. -(
_app.AllowYieldOnMsg := true //allows messages in queue to be dealt with
do while not eof()
_app.executeMessages() //prevents message from becoming full
if recno()%5 = 0 //not less the 2.
clear
endif
? 'Record Number: ' + ltrim(str(recno()))
main stuff...
skip
enddo
clear window
A better proposition is to create a small form. Here you will be able
to display the record number as it is dealt with. A form does, of
course, make a progress bar feasible. The rowset created by a query
object does not understand recno() so one needs to DIY to keep track of
the records.
The attached example may give you some ideas.
Object oriented event driven programming for Windows is completely
different to programming for DOS. It is not particularly difficult to
learn but it does take a concerted effort. The hard part is forgetting
the old ways. :-) It is almost essential to complete the dBASE Tutorial
before you try to convert existing programs or write new ones.
Mervyn.
| ** END HEADER -- do not remove this line
//
// Generated on 2020-06-17
//
parameter bModal
local f
f = new Ketan1Form()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class Ketan1Form of FORM
with (this)
onOpen = class::FORM_ONOPEN
height = 16.0
left = 61.5714
top = 2.7727
width = 40.0
text = ""
endwith
this.DBASESAMPLES1 = new DATABASE(this)
with (this.DBASESAMPLES1)
left = 17.0
width = 11.0
height = 1.0
databaseName = "DBASESAMPLES"
active = true
endwith
this.CUSTOMERS1 = new QUERY(this)
with (this.CUSTOMERS1)
left = 6.0
top = 1.0
width = 9.0
height = 1.0
database = form.dbasesamples1
sql = "select * from CUSTOMERS.DBF"
active = true
endwith
this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = class::PUSHBUTTON1_ONCLICK
height = 1.0909
left = 9.2857
top = 9.0909
width = 15.2857
text = "Start"
endwith
this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
height = 1.0
left = 18.1429
top = 3.6364
width = 8.0
value = 0
endwith
this.TEXTLABEL1 = new TEXTLABEL(this)
with (this.TEXTLABEL1)
height = 1.0
left = 5.2857
top = 3.7273
width = 12.0
text = "Record No"
endwith
this.rowset = this.customers1.rowset
function PUSHBUTTON1_onClick()
form.customers1.rowset.first()
n = 0
do while not form.customers1.rowset.endofset
n++
_app.executeMessages()
form.entryfield1.value = n
// anything that needs to be done goes here
sleep(.05) //a pause here for the test otherwise
//everything happens so fast that it looks as if
//the program has gone straight to the last record
//without doing anything.
form.customers1.rowset.next()
enddo
return
function form_onOpen()
_app.AllowYieldOnMsg := true
return
endclass
|
|