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

How to pass a return code from FoxPro back to Dos. 2

Status
Not open for further replies.

iyarosh

Programmer
Apr 14, 2003
49
US
I know that this is something simple, but I've spent few hours and could not find anything??? I'm running my foxpro 6 program from dos cmd and need to capture the execution code returned by my program in dos. If it's not possible what would be my alternative to pass the code from app back to OS? Thanks!
 
You can't. Fox doesn't support returning an execution code. The alternative is to create a text file for each return code, then check for the file.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports"
 
Hi iyarosh,

I believe Fox can return values, if that is what you are looking for.

Note: Execution code is different from values returned.

For example.. in your main.prg as the last statement before doing a QUIT.. i suggect dont use QUIT but instead use.. RETURN gcReturnValue

Make sure gcReturnValue variable is available at the place where VFP exits. Probably, you declare that PUBLIC so that wherever you set its value within the application, it is available at the RETURN place.

If you are using a single form as your main form, you should declare PUBLIC gcReturnValue in your Init of form and in the form somewhere, the value gets assigned and in the unload event of the form..
RETURN gcReturnValue
(Instead of public, you can make that a form variable also)

But having main form cannot return an application value back. It will only retunr .T. as the value returned.
SO the way to get this done is... start a Main.PRG in the application. make the PRG as the main in the exeutable.
Add the code in the main.prg
DO FORM myFORM TO myRet
RETURN myRet

Then compile and test. The VFP execuatable will return the value correctly.

How do you receive the value in the DOS is a different story.
:)




____________________________________________
ramani - (Subramanian.G) :)
 
Baltman,

From what Craig and Ramani said looks like I would no be able to send return codes back to DOS, but in case you have a different idea here is why I need it: I have a bunch of DOS .bat processes that are executed by NT scheduler and 1. map the share drive to the letter process is using and 2. run Fox programs. This is how it was done before and I intent to keep it the same way, but now we want to move these jobs from NT scheduler to 3rd party product that monitors the whole execution of the job and the only way for that monitoring tool to know whether the job succeded or failed is to get the return code from the process. Thanks!
 
You say that you want to get Return values from your scheduled jobs.

I assume that the scheduled jobs do not currently have ANY provision for returning status parameters, etc.

In that case, you will need to modify the programs anyway, so why not modify them in such as way to as return a status code and/or parameter either via the text file approach mentioned above or via a new monitoring table.

It is not totally clear (to me anyway) what application is the "monitoring tool to know whether the job succeded or failed is to get the return code from the process".
Is it your VFP 6 application?

If so then the scheduled DOS applications might just as soon write their completion status parameter and date/time into a table which the VFP monitoring program can read.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top