×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

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!

*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

Infinite loop with exit on condition - need timed slowdown

Infinite loop with exit on condition - need timed slowdown

Infinite loop with exit on condition - need timed slowdown

(OP)
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

RE: Infinite loop with exit on condition - need timed slowdown

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.


 

RE: Infinite loop with exit on condition - need timed slowdown

(OP)
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

RE: Infinite loop with exit on condition - need timed slowdown

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

RE: Infinite loop with exit on condition - need timed slowdown

(OP)
Aiden,

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

Regards,

Ilya

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

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