Solved

Passing foxpro variable to Visual studio project

Posted on 2010-08-26
5
610 Views
Last Modified: 2013-11-27
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
Comment
Question by:redrp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 14

Accepted Solution

by:
tusharkanvinde earned 188 total points
ID: 33538934
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
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 187 total points
ID: 33539509
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
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33540007
"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
 
LVL 12

Assisted Solution

by:jrbbldr
jrbbldr earned 125 total points
ID: 33542082
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
 

Author Closing Comment

by:redrp
ID: 33546927
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question