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!

Restart Program

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
US
I am closing myApp down and restarting it after a user click OK on the msgBox. I issued:
CLEAR ALL
CLOSE ALL
DO myApp.exe

but I am getting errors like the toolbar isn't found. Am I missing something here?

Thanks
 
I think your approach isn't quite doing what you think it's doing. "DO MyApp.EXE" will run the EXE file within the same instance of the FoxPro Runtime environment.

Instead of using the DO command, I would recommend using the RUN command with /N or an API call to ShellExecute, then allow the program to terminate. The RUN command would look like this:
Code:
RUN /N MyApp.EXE

Ian
 
Ok this is the code that is being used to check if the program is running:

=ddesetoption( "SAFETY", .f.)
*Check to see if DDE service was already started.
achan = ddeinitiate( "pkf4", "System" )
IF achan # -1
WAIT WINDOW "Application is already running. It may take a few seconds to load so please be patient."
QUIT
ENDIF
*If we got here, the service was not started, so start it.
=ddesetservice( "pkf4", "DEFINE" )


I do some stuff from the menu of the app and in the end after user click on a msgBox I issue the following command to restart the program, but something is wrong in this.

if
.......
msgbox(......)
achan = DDETerminate("pk4")
clear events
Clear all
Close all
RUN /N ianera.EXE
endif
 
What happens in your main PRG file after your READ EVENTS command? Does the program terminate if you simply issue CLEAR EVENTS without the rest?

Without knowing much about your program, perhaps if you put CLEAR EVENTS as the LAST line in the procedure it might work.
Code:
if
      .......
      msgbox(......)
      achan = DDETerminate("pk4")
      Clear all
      Close all
      RUN /N ianera.EXE
      clear events
endif
Ian
 
Yes I just have issue Clear Events to close the program.
This is what I tried now:

if
.......
msgbox(......)
Clear events
Set safety on
RUN /N myAPP.EXE
endif

The program closes w/o giving any errors like toolbar not found. The new instance starts and get the wait window from the main.prg saying WAIT WINDOW "Application is already running. It may take a few seconds to load so please be patient."

After pressing any key everything closes down.

Follwoing is the code after READ EVENTS in Main.prg(myApp.prg)

FLUSH()
RELEASE WINDOWS
thetool.release
CLOSE TABLES ALL

CLOSE DATABASES ALL
CLOSE TABLES ALL
ON ERROR
ON SHUTDOWN
SET SYSMENU TO DEFAULT]

If I add this before the RUN /N command I get the error # 108 /109.


 
Ahh, ok. The problem you're running into with the changes is that you're doing the CLEAR ALL and CLOSE ALL before flushing and other maintenance stuff. That causes the errors.

Try removing the CLEAR ALL/CLOSE ALL lines and see how it works. And make sure you shut down the DDE server before trying to run the app again (I noticed you didn't include it in that last post).

Ian
 
Hey Ian:

It worked. Thanks for guiding me toward the 'READ EVENTS' thing.

Ashish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top