R – VFP to .Net Compiler

foxpronetvisual-foxpro

Has anyone had experience of or got any knowledge about the VFP to .Net Compiler?

I'm working for a company with an extensive range of VFP9 applications and they are looking for a quick way to get apps running in .Net. I've been asked to check out this compiler to see if it is a viable option but so far I haven't been able to get it to successfully compile anything – even my "Hello World" world application doesn't run.

Just to qualify that last remark: I can get really simple Fox apps to "compile" but the .Net executable that is produced does not execute successfully. I've dissassembled the source and turned it into C# but generally it contains many errors (100+).

I'm tempted to dismiss the whole technology out of hand however there seems to be lots of support for this and excitement about it the Fox user community. Does anyone have any insight into this?

Here is a link to the VFP to .Net Compiler

Best Answer

I now have some experience with the VFP to .Net Compiler which you can find here.

This is actually a compiler for .Net and has nothing to do with COM Interop or Web Services. The whole thing is built around SharpDevelop which ships with the compiler. Effectively you can fire up SharpDevelop and type in a FoxPro PRG. There is full in intellisense and most if not all Fox commands and functions are supported. When you hit compile, what comes out the other side is a full .Net assembly.

If you run the assembly there is no instance of VFP and no COM interop in sight. How does it work? The guys behind it have created .Net functions which map onto the Fox functions, so for example if you call the StrToFile() this is the code that actually runs (brought to you by the wonders of Reflector):

public static void StrToFile(string cExpression, string cFileName)
{
    if (File.Exists(cFileName))
    {
        File.Delete(cFileName);
    }
    FileStream stream = new FileStream(cFileName, FileMode.CreateNew, FileAccess.ReadWrite);
    StreamWriter writer = new StreamWriter(stream);
    writer.Write(cExpression);
    writer.Flush();
    writer.Close();
    stream.Close();
}

What this means is that if you are very productive in Fox but you a need .Net solution you can code in Fox and produce a .Net assembly.

I would however advise some caution as not everything is implemented as nicely as the StrToFile example above. The way it models things like Fox forms is pretty awful, although it does work (you can take an existing Fox form and add it to SharpDevelop and it will turn it in to a .Net form). If anyone wants any more detail I'll be happy to expand on this.