Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Infinite loop with exit on condition - need timed slowdown 1

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
571
US
Colleagues,

We have a program (in dBase, EXE, quite old) that calls another program (in VFP9, also EXE) and sits in the infinite loop waiting for that VFP program to create some table file (DBF, compatible with both, dBase and VFP9). This lil' DBF is kind of a data transporter between these two programs. The problem is that, since this interaction is conducted via network channels, VFP program does not always have enough time to finish data transfer before dBase program grabs that DBF - and finds it either empty or worse...
The code in the dBase program is quite simple:

Code:
Run(.T.,"&cWhereIs\VFP_Program.exe"...)

cFile = cWhereIs+"\rtndata.dbf"

do
   *// loop
until file(cFile)

We need to slow down this loop processing. Can't use INKEY(.1), it's out of the question koz the VFP program can be minimized and ... you've got the picture.

Neither could I find Timer object in the dBase's Help.

What other means are there in the ol' good Visual dBase 5.7 for Windows to make this DO...UNTIL wait, say 0.1 second on each iteration?

TIA!



Regards,

Ilya
 
Ilya,

One way around is to have the file that dBase is waiting for not be present until it is created. Then just to a iteritive call to an IF FILE and check for it.

One other thought is to figure out how long it takes, at the most, to create the DBF and have the dBase program wait that long until it tries to access the DBF.

Jim C.


 
Jim,

That's exactly the question: what there is, in dBase, that can be used in liew of timer? U C, even if I new it takes, say, 2.75 seconds, - what do I use to set this delay?

Thanks!

Regards,

Ilya
 
Ilya,
The following works in dbase for dos maybe you can use this code to do the same for visual dbase

* WWAIT
* User defined pause routine to nearest 100th of a second centisecond).
* Pass the delay in centiseconds as a parameter. (Max is 23:59:59.00
* Program continually looks at internal PC clock until
* Current Time - Start Time > Aim Time.
* Used to reduce frequency of polling in web development for purposes of
* optimising performance of web site

parameters mdelay
mhours=str(set("hours"))
set hours to 24
mmax=centisecs("23:59:59.00")
mday=mmax+100
mstart=centisecs(time("x"))
mcontinue=.t.
do while mcontinue
mnow=centisecs(time("x"))
* Add a day if "now" is earlier than start, because we've crossed midnight
mcontinue=(mnow-mstart+iif(mnow<mstart,mday,0))<(min(mdelay,mmax)/2)
enddo
set hours to &mhours
return

function centisecs
parameter clock
* Convert time into numeric 100ths of a second since start of day
return (((((val(substr(clock,1,2))*60)+val(substr(clock,4,2)))*60)+;
val(substr(clock,7,2)))*100)+val(substr(clock,10,2))

You would call the program/function as do wwait with 400 etc

I hope this is some help

Thanks

Aiden
 
Aiden,

it's a great idea!
Thank you very much!
I will pass this your idea to my dBase people!

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top