>Based on the info I found in the FAQ (#443 by Ed Rouh), I tried creating a RetTest.exe and and associated BAT file to capture an error level. Can anyone suggest what I might be doing wrong as no matter what I do, there does not appear to be anything returned. I say this because my BAT file always echos "Nothing was returned". Any suggestions would be greatly appreciated.
>
The API call you're looking at allows you to exit from -VFP- and return an exit code. You're launching a WinApp from a batch file - a batch file does not wait on the completion of the WinApp by default. You can use the START verb in the .BAT file to force the .BAT file to wait on VFP to complete before continuing to execute.
You can prove this to yourself easily - open an MSDOS command line session, and issue the command
NOTEPAD. Don't close NotePad - you'll see that the DOS session has returned control to the command processor, and is waiting on your input with a fresh DOS prompt. Close notepad. Try the same thing, this time with the command line
START /WAIT NOTEPAD - you'll discover that you will not get a DOS prompt back until notepad (another WinApp) has finished running.
IOW, it's a problem with how you think .BAT files work...DOS sessions are not conducive to incorporating WinApps. You might want to invest some time in learning about the WIndows Scripting Host.
>TIA - Isaac
>
>Here is my prg and bat files ...
>
>************************************************
>** RetTest - Testing for returned error level
>LOCAL lnReturnVal
>lnReturnVal = 1
>DECLARE ExitProcess in Win32API INTEGER ExitCode
>=ExitProcess(lnReturnVal)
>RETURN
>************************************************
>
>
>REM Here is my bat file called test.bat
>@echo off
>
>RetTest
Instead of this, try:
START /WAIT RetTest
>goto answer%ERRORLEVEL%
>
>:answer0
>echo Zero was returned
>goto end
>
>:answer1
>echo Negative one was returned
>goto end
>
>:answer
>echo Nothing was returned
>goto end
>
>:end