Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PROCESS.VCX
Message
From
24/11/1999 11:52:02
 
 
To
24/11/1999 11:38:58
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
00295080
Message ID:
00295085
Views:
19
>Ed,
>I saw your solution to the problem of running dos programs in
>VFP6 and making sure that the dos program is finished before
>VFP continues on the Universal Thread. I downloaded the
>PROCESS.vcx class and included it in my project. Let me first
>state that I am new to working with VFP and classes. My app
>has to run batch programs that FTP files from one sever to
>another. Here is the code that I am using with your class:
>
>Set classlib to process additive
>oapprun=createobj('api_apprun','c:\dataflow\barbatch.bat','c:\dataflow',"min")
>oapprun.launchappandwait()
>do while .t.
> if oapprun.CheckProcessExitCode()=259
> loop
> else
> exit
> endif
>enddo
>release oapprun
>
>I saw in a message that I can poll the CheckProcessExitCode
>for a value other than 259 to make sure it has ended before
>proceeding with the rest of the program. This code is inside
>of a timer that is set to false by the time it gets to this
>code. My problem is that I have to insert a wait window with
>a timeout of 5 seconds after this code. If I take the wait window
>out, the timer code is started all over again for some reason.
>Do you see anything wrong with this sample code or is there
>a better way to check for the termination of the program?
>
>I really appreciate any direction that you may lend me!!

The problem is that the batch file is not terminating the DOS session on it's completion. You need to create a PIF file for the .BAT, telling it to close down when it completes. Go into Windows Explorer, find the .BAT file, right click, select Properties, and on the Program Tab and make sure the Close on Exit checkbox is checked. Once you've done this, the batch file will close down the DOS session on completion and CheckProcessExitCode() will return a value other than 259.

I try to steer away from .BAT files - you might want to look into the Window Scripting Host, a much more capable and toolkit than the .BAT file. It's incorporated into Win98 and Win2K, and can be added to Win95 and WinNT 4 through installation of IE, Option Pack 4, or best, the self-installing WSH executable that can be downloaded from msdn/microsoft.com/scripting, which works pretty much cross platform as long as you have Win95 SP1 or later or WinNT 4.0 SP3 or later.

>
>Joe Glen
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform