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

How to run .FXP from .NET

Status
Not open for further replies.

ebase

MIS
Jan 7, 2004
40
0
0
US
Hello all,

My co-worker is having some issues trying to get a .FXP file he created in FoxPro to run in .NET. Can someone direct me to some sources that shows how we can call the .FXP program to run from .NET.

Thanks in advance!
K
 
Couldn't edit the first post but wanted to add if anyone also knew how to call the .prg file made in FoxPro from .NET (C++).

Thanks again.
K
 
You'll need to make a project out of the functions/functionality the fxp provides and compile a dll or exe com server. Not knowing exactly what your prg code does, might I suggest creating an OLE Public class with the methods and properties you want to make available to the .NET application (will greatly simplify things and make everything more maintainable and scalable moving forward).

This is unmanaged code of course (doesn't go through the framework per se), but no other way that I know of to make VFP functionality that you've written available for use in a .NET application.

For what it's worth: Same holds true the other way, in order to use .NET stuff from within a VFP application you'll need to compile a dll from within .NET.

boyd.gif

 
Thanks Craig.

My co-worker created an .exe file and when we run it, the FoxPro window comes out when it's running and closes when finished. (It basically just reindexes one table) I want to put the .exe in the task manager to run it daily but would like to know how to stop it from opening a window when it runs.

Any ideas? Thanks,
Kei
 
Hi Kei,

You don't need a form. Just compile a prg that does your indexing. Put _screen.Visible = .F. at the start.

Regards,

Mike
 
Thanks Mike. I will let him know of this and see what happens. Thank again for all of your help!

Kei
 
Hi Kei,

_screen.Visible at the start of the prg will cause a momentary flash of the VFP screen. It would be better to have a config.fpw file included in the project with SCREEN=OFF.

Regards,

Mike
 
Another question if I may. The current foxpro file is very simple:

use D:\A\Data\syusess.dbf
Reindex
use

and I have the program, reindex.exe, under D:\program. If I were to use this in a command prompt, a simple D:\program\reindex.exe would run this but is there a way to:

COMMAND PROMPT
D:\program\reindex.exe D:\abcd

and have the abcd go into the acutal program like:

use D:\abcd\syusess.dbf
Reindex
use

so it basically replaces or adds the D:\abcd into the foxpro program. Sorry if I'm not explaining this correctly.

K
 
It sounds like you want to pass a parameter into the executable. Easy.

You need to add an LPARAMETERS statement to tell Fox what parameter to expect and then quote this parameter in the code:

Code:
LPARAMETERS lcPath    && Path to the table
LOCAL lcTable         && Full name and path of the table

lcTable = ADDBS(lcPath) + "syusess.dbf"
use &lcTable
Reindex
use

Note that the & is to make FOx evaluate the variable lcTable. A plain "USE lcTable" would have Fox looking for a table named "lcTable.dbf".

Geoff Franklin
 
Change

Code:
use &lcTable

to...

Code:
Use (lcTable)


...two reasons for this. First, if the fullpath to your table has any spaces in it then the macro substitution will give you an error. Second, macro substitution is much slower/resource intensive (relatively anyways, for a single line like this we are talking a difference of quite a few nanoseconds). Avoid macro substitution when another, just as easy way presents itself.

boyd.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top