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

Shell out to wordpad executes next inst before shellout

Status
Not open for further replies.

sfr10000

Programmer
May 22, 2006
12
0
0
DO
If I shell out to NotePad it works fine, but if I Shell out to WordPad the instructions after the shell out get executed before the Shell Out. The only way I have found to make it work correctly is to put a "Wait" following the Shell out. I'm sure it's somthing simple but so far I cant seem to figure it out.
 
Use do while findwindow() <=0. Might want to error out if it takes too ling. See example here faq184-2725. Also, use sleep API instead of wait. Not affected by users and CPU friendly.

Code:
DECLARE Sleep IN Win32API INTEGER

sleep(100)
 
The only way I have found to make it work correctly is to put a "Wait" following the Shell out.

I do exactly the same. As you have found, you have to wait for the target application to load. Wordpad probably takes longer to load than Notepad simply because it's bigger.

That said, I agree with Baltman that the way to do the wait state is with Sleep().

In fact, you should do this with Notepad as well. It might load "instantly" on your system, but you can never be sure that's the case for the end user.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top