none
vars.mem RRS feed

  • Question


  • Since I'm not a Foxpro guy... I need some help.

    We need to consume data from an old DOS app for which we don't have the source code.  It might be FoxPro.  We have a c# app that needs to parse out a file called vars.mem.  It looks to be a Foxpro variables file.  It is not exactly text, but it is close. 

    I'm hoping that there is some easy way to open it and extract the data.  The response I'm hoping for is "you need to use the OLEDB provider for FoxPro variables files and it will be totally easy."  A guy can dream, right?

    Any suggestions are appreciated. 



    Wednesday, June 11, 2008 8:34 PM

Answers

  • I wrote a mem file parser which can be used to walk through the data variable by variable or produce a Dictionary type containg name value pairs that represent all of the variables. From my tests I believe I have proper support for all cases including data types such as two dimensional arrays. If I get the go ahead to share the code I'll post it on my blog and link back to it here as well.
    Friday, October 22, 2010 2:05 AM
  • Although the original question is already two years ago, I'll want to add another solution for searching souls: I wrote a MEM-File Converter. It's available at http://code.msdn.microsoft.com/foxpro

    wOOdy
    Microsoft Visual FoxPro Technology Advisor
    Microsoft "Most Valuable Professional" from 1996 to 2009
    Visit my XING profile!

    *´¨)
    ¸.·´¸.·*´¨) ¸.·*¨)
    (¸.·´. (¸.·` *
    .·`.Visual FoxPro: It's magic !
    (¸.·``··*


     

    Friday, October 22, 2010 7:56 AM

All replies

  • I don't think you could use vfpoledb for that, use VFP or foxpro (or request someone who has foxproto do that).

    Wednesday, June 11, 2008 10:41 PM
  • Unfortunately I've got some more bad news. The format of a .mem file was never documented, and actually changed between versions when new features and variable types were added. The 'official' line was to save the data off to a table before updating to a new version. .mem files were only meant to save off data that might exist in one part of the program and not another - especially when we were restricted to less than 640kb. Data that was needed between runs of the application was (should have been?) always stored in tables (.DBFs).

     

    Rick

     

    Thursday, June 12, 2008 2:48 AM
  • The VFP OLEDB Provider is not only a database driver, it allows access to many functions. Some of those documented not available with OLEDB can be used by calling EXECSCRIPT.

     

    So you may try VFPOLEDB and prepare a command this way:

     

    Code Snippet

    using System;
    using System.Data;
    using System.Data.OleDb;
    using System.Diagnostics;

    class test
    {
      static void Main()
      {
        string strCon = @"Provider=VFPOLEDB;Data Source=c:\My Folder";
        OleDbConnection con = new OleDbConnection(strCon);
        OleDbCommand cmd = con.CreateCommand();

        con.Open();   
        string strScript = @"RESTORE FROM d:\some\path\to\vars.mem

        LIST MEMORY TO d:\some\file.txt";
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "ExecScript";
        cmd.Parameters.Add("myScript",OleDbType.Char).Value = strScript;
        cmd.ExecuteNonQuery();
        con.Close();
     }
    }

     

     

    This woulld create a text export of the vars, if it works. But Both RESTORE FROM and LIST are officially unsupported functions of the VFP OLEDB Provider and the chance is high, that the mem file is in a format not compatible with VFP9. How large is the mem file? How many of them do you have to read?

    • Unmarked as answer by Martin_Xie Friday, October 22, 2010 3:58 AM
    Friday, June 13, 2008 4:42 PM
  •  

    Hi Olaf,

     

    I also need to get inside a mem file.  I've tried the above code (changing the paths as neccesary) but i'm getting 'Feature Not Available' (everyone's favourite VFP error!) on the ExecuteNonQuery().  Any clues? Do I need any other VFP dlls installed apart from the VFPOLEDB driver?

     

    Many Thanks

     

    James

    Monday, September 8, 2008 11:00 AM
  •  Olaf Doschke wrote:

    The VFP OLEDB Provider is not only a database driver, it allows access to many functions. Some of those documented not available with OLEDB can be used by calling EXECSCRIPT.

     

    So you may try VFPOLEDB and prepare a command this way:

     

    Code Snippet

    using System;
    using System.Data;
    using System.Data.OleDb;
    using System.Diagnostics;

    class test
    {
      static void Main()
      {
        string strCon = @"Provider=VFPOLEDB;Data Source=c:\My Folder";
        OleDbConnection con = new OleDbConnection(strCon);
        OleDbCommand cmd = con.CreateCommand();

        con.Open();   
        string strScript = @"RESTORE FROM d:\some\path\to\vars.mem

        LIST MEMORY TO d:\some\file.txt";
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "ExecScript";
        cmd.Parameters.Add("myScript",OleDbType.Char).Value = strScript;
        cmd.ExecuteNonQuery();
        con.Close();
     }
    }

     

     

    This woulld create a text export of the vars, if it works. But Both RESTORE FROM and LIST are officially unsupported functions of the VFP OLEDB Provider and the chance is high, that the mem file is in a format not compatible with VFP9. How large is the mem file? How many of them do you have to read?

     

    Olaf,

    Yes it is not just a database driver and allows you to do many things via execscript but not everything. I would again say that I don't think you could do that with VFPOLEDB. Did you really try it and worked?

     

    Ole automation with vfp.application might work but I don't think VFPOLEDB.

    Monday, September 8, 2008 11:30 AM
  • I've tried your suggestion and unfortunately I get the following exception.

     

    System.Data.OleDb.OleDbException occurred

      Message=Feature is not available.

      Source=Microsoft OLE DB Provider for Visual FoxPro

      ErrorCode=-2147467259

      StackTrace:

           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)

           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)

           at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)

           at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)

           at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)

           at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

           ...


    Wednesday, October 6, 2010 9:35 PM
  • I've tried your suggestion and unfortunately I get the following exception.

     

     

    System.Data.OleDb.OleDbException occurred

      Message=Feature is not available.

      Source=Microsoft OLE DB Provider for Visual FoxPro

      ErrorCode=-2147467259

      StackTrace:

           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)

           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)

           at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)

           at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)

           at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)

           at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

           ...


     

    Although it has been marked as an answer by someone you should read all the messages. I think I have already said that it wouldn't work.
    Tuesday, October 12, 2010 10:22 AM
  • I wrote a mem file parser which can be used to walk through the data variable by variable or produce a Dictionary type containg name value pairs that represent all of the variables. From my tests I believe I have proper support for all cases including data types such as two dimensional arrays. If I get the go ahead to share the code I'll post it on my blog and link back to it here as well.
    Friday, October 22, 2010 2:05 AM
  • Thank you All for your suggestions and friendly help. I'm glad to see your active discussion.

     

    Hi kainhart,

     

    Your reply looks promising to resolve customer's question. We all look forwad to your "mem file parser" code sample and reading your blog. It will be very beneficial for other community members who have the similar questions.

     

     

    Best regards,

    Martin Xie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, October 22, 2010 4:06 AM
  • Although the original question is already two years ago, I'll want to add another solution for searching souls: I wrote a MEM-File Converter. It's available at http://code.msdn.microsoft.com/foxpro

    wOOdy
    Microsoft Visual FoxPro Technology Advisor
    Microsoft "Most Valuable Professional" from 1996 to 2009
    Visit my XING profile!

    *´¨)
    ¸.·´¸.·*´¨) ¸.·*¨)
    (¸.·´. (¸.·` *
    .·`.Visual FoxPro: It's magic !
    (¸.·``··*


     

    Friday, October 22, 2010 7:56 AM