Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exiting VFP returning an error level
Message
De
30/11/1999 11:23:27
 
 
À
30/11/1999 11:08:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00296903
Message ID:
00296906
Vues:
29
>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
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform