Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 620
  • Last Modified:

Passing foxpro variable to Visual studio project

Hello Experts,

I am trying to create a simple application in visual studio but i need to get variable data from an ancient foxpro program. What i am looking to do is have the foxpro application run the Visual studio program and pass information to VS to manipulate. In Foxpro you can pass variables to dos windows but I lack understanding of how that works. Can anyone help?

Thank you,

John
0
redrp
Asked:
redrp
3 Solutions
 
tusharkanvindeCommented:
If this is visual foxpro, you can use shellexecute

DECLARE INTEGER ShellExecute IN shell32.DLL INTEGER hndWin, STRING cAction, ; STRING cFileName, STRING cParams, STRING cDir, INTEGER nShowWin
shellexecute(0,'Open',cExecutableFileWithFullPath,"YourParameters here","",1)

If it is Foxpro for DOS, you can create a .BAT file and then run it

lnHandle=FCREATE('temp.bat')
=FPUTS(lnHandle,'YourCommandWithParameter')
=FCLOSE(lnHandle)
Run temp.bat

Or you could try directly running it from foxpro
RUN YourExeFileWithPath YourParameters
0
 
Olaf DoschkeSoftware DeveloperCommented:
All the options tushar gave work via "command line options" of other EXE files. And foxpro itself can accapt parameters this way by having an lparameters line in it's main prg. The same goes for C projects with their main function.

In VB.NET you define a Main function this way:

Imports System

Namespace Hello
   Class HelloWorld
      Overloads Shared Sub Main(ByVal args() As String)
         Dim name As String = "VB.NET"

         'See if an argument was passed from the command line
          If args.Length = 1 Then name = args(0)

          Console.WriteLine("Hello, " & name & "!")
      End Sub
   End Class
End Namespace


In C# this way:

using System;

namespace Hello {
   public class HelloWorld {
      public static void Main(string[] args) {
         string name = "C#";

         // See if an argument was passed from the command line
         if (args.Length == 1)
            name = args[0];

         Console.WriteLine("Hello, " + name + "!");
      }
   }
}

With that these mechanisms of Shellexecute, RUN or a .BAT file would all work.

If you need to get a parameter in somewhere in the middle of running a .NET exe there are other means of interoperability, you can create a .NET assembly with COM interop and use that within VFP like any COM class via CreateObject or vice versa create an OLE PUBLIC class in VFP and use it in .NET. Last not lease you can use interprocess communication variants like shared memory or pipes or windows messages or message queues.

Command line options is the simplest but limited to passing values at the start of course.

Bye, Olaf.
0
 
Olaf DoschkeSoftware DeveloperCommented:
"In Foxpro you can pass variables to dos windows"

You most probably have pipes in mind in regard to DOS. That is mostly StdIn, StdOut and StdErr. The concept is not limited to DOS, but it's one of the interprocess mechanisms, and both applications must comply to it, eg you can't pass in something to a StdIn pipe of another program if that other program doesn't provide a StdIn pipe, it's not there by default.

Interprocess communication is always something done by both sides actively. Of course receiving paramaters at start is also something provided to any outside process by an exe, but it is one way, not interactive as interprocess communication.

Bye, Olaf.
0
 
jrbbldrCommented:
All of what was suggested above is good.

There is yet another way - to pass parameters via a data table.

Your Foxpro application can populate a data table with its parameters and then call the 'alien' program which in turn can read the parameters from the same data table.  
Or vice-versa if the 'alien' program was to call the Foxpro one.

Good Luck

0
 
redrpAuthor Commented:
Hey experts,

Thank you for all of the great info. I have decided to split the points between the lot of you for the awesome answers you all gave.

Thanks,

John
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now