Solved

Passing foxpro variable to Visual studio project

Posted on 2010-08-26
5
596 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Fox Pro commands 15 50
How and where to get Business Intelligence Development Studio? 2 93
DBF to ... Converter 5 82
SSRS Deployment problem 5 66
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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