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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait command with no output. 2

Status
Not open for further replies.

inteleserve

IS-IT--Management
Dec 13, 2002
75
0
0
US
What is the best way to make my foxpro program wait for a specified number of seconds without any output to the screen or requied anykey pressing.

Why doesn't this work?

WAIT CLEAR TIMEOUT 1

 
This is what I use:
Code:
procedure Delay
parameter s
private zz
  DECLARE Sleep IN Win32Api AS apiSleep LONG dwMilliseconds
  zz = s*1000
  apiSleep( zz )  
ENDPROC

I expect Sleep will allow Windows to do whatever it wants in the most cooperative way possible...
 
I see that my solution doesn't answer your question - it displays a message.....

Jim
 
WAIT CLEAR terminates a previous WAIT NOWAIT command - there is no TIMEOUT option on a WAIT CLEAR, you should be getting a syntax error. (The Help file is not real "clear" on this!)

Use the Sleep() WinAPI function instead.
Code:
DECLARE Sleep IN Win32API LONG
=Sleep(1000.0) && one second
Note: Sleep works in milliseconds.

Rick



 
***this is an old piece of code, but should work too


waitsecs=10
DO WHILE waitsecs>1
holdon=substr(time(),8,1)
do while .t.
testtime=substr(time(),8,1)
if testtime<>holdon
holdon=substr(time(),8,1)
exit
endif
enddo
waitsecs=waitsecs-1
?waitsecs
ENDDO
 
I typed it in exactly like:

DECLARE Sleep IN Win32API LONG=Sleep(1000.0)


and I get a syntax error..........


help?
 
HandleMeNow,
While this was fine for a DOS environment, in Windows this will "burn" the processor, and keep other applications from handling Windows messages. This is often refered to as a "bad actor" piece of Windows code. Note: If you include a DOEVENTS command inside your loop, it would be much better!

Rick
 
@rgbean Rick

thanks, you are right, I did't consider the window environment with other applications.

Erik
 
inteleserv: It is meant to be two lines:
Code:
DECLARE Sleep IN Win32API LONG

=Sleep(1000.0)

The "=" isn't really necessary... it's just how I typed it way back... This works too:

Code:
DECLARE Sleep IN Win32API LONG nNumberOfMiliseconds
Sleep(1000.0)
 
marzz,
While this doesn't display a Wait box, it can be overridden with a simply key press or mouse click - then it really isn't waiting!

Rick
 

This is what I have ended up useing and it works great.

DECLARE Sleep IN Win32API LONG
Sleep(1000.0)

Thanks rgbean and wgcs

how come i don't need anything after LONG?
 
You don't need any thing after LONG because this is just a declaration of the function signature.
Long here is the Parameter Type (just the type not the parameter itself).
you next send the parameter in the function call.
Sleep(1000.0)
the 1000 is the parameter of type LONG that the function Sleep expect you to send.


Walid Magd
Engwam@Hotmail.com
 
Just one more!

=inkey(5,"H")

will wait for 5 seconds and hide the cursor
the only issue with this simple method like the wait timeout 5 is a keypress will interupt the wait.


Steve Bowman
steve.bowman@ultraex.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top