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

Calling .PRG within EXE 1

Status
Not open for further replies.

Rogy

Programmer
Nov 20, 2002
43
0
0
SI

I have a program compiled in EXE that should be run once
a day. Is there a way to call program file within EXE?

Thanks!
 
Do you meant you want to call a FoxPro PRG file from the EXE? If so, then just go ahead and DO the file. Provided the file is stored in the default directory or on the VFP search path, your program will find it and run it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
If you want to call the PRG inside the EXE from another VFP applications, SET PROCEDURE TO MyApp.EXE, then DO MyProg.PRG.

Doug
 

I should be more specific. :)
I am not calling PRG from VFP, Mike. I want to call it from
Task Scheduler in WinXP. PRG is inside EXE.
It should be something like that (I think):
RUN Program.EXE with "prg1.prg"


P.S.:I am using VFP 8
 
You would have to add a PARAMETERS statement to the beginning of the main prg in the EXE and logic to call your prg if you passed a parameter as you have stated. Then you could schedule a BAT file to execute the EXE

MYEXE.BAT (has the following lines)

MYEXE.EXE PRG1.PRG
EXIT




Andy Snyder
SnyAc Software Services
 

Andy I tried as you wrote, but it didn't work.
- I added "PARAMETERS lpar1" in Main.PRG
- rebuild the project(EXE)
- RUN in BAT file as you wrote

The application runs, but nothing happens.
 
Rogy,

I want to call it from Task Scheduler in WinXP. PRG is inside EXE.

I have to say that no-one could have guessed that from your question. But still ..,.

Andy has put you on the right track. You need to do something like this:

If the EXE is called MyExe.EXE, put this command in the scheduler:

Code:
MyExe.EXE 1

In the main program within MyExe, start with the following:

Code:
PARAMETERS tcParam

IF tcParam = "1"
  DO MyProg.PRG
ELSE
  * Do whatever else you want to do
ENDIF

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike...!
Now It works as I needed.

P.S.: Yes, the first question was strange...
Sometimes you think one thing and type something else. :)
 
Thanks Mike.... your code example is exactly what I was suggesting. The only change I would suggest is...

MYEXE.EXE
Code:
PARAMETERS tcParam

IF pcount()#0 .and. tcParam = "1"
  DO MyProg.PRG
ELSE
  * Do whatever else you want to do
ENDIF

Andy Snyder
SnyAc Software Services
 
Don't make it so complicated. If all you want to call is the prg, then simply make a project, make the prg the main project file and compile to an exe. Calling the exe then means executing the prg, much simpler...

If the prg is just part of the exe and you don't want to touch the exe as it is or you always want to run the version of the prg inside a certain exe, you should make use of Doug Hennigs example and write a program like this:

Code:
SET PROCEDURE TO some.EXE
DO some.PRG

make this the main prg of some new project, compile it to caller.EXE and put it right beside some.EXE and call it with the task scheduler.

if you want to run different programs from inside some.exe, make it a parameterized caller.exe

Code:
LPARAMETERS tcProgramtocall
SET PROCEDURE TO some.EXE
DO (tcProgramtocall)

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top