Solved

Passing foxpro variable to Visual studio project

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now