none
How to create a console application in FoxPro RRS feed

  • Question

  • Hello,

     

    I mainly write code in C# & VB.NET, however, I've been asked to create a "console application" in FoxPro 8.  Is this possible?  Can someone point me to a "walk through" or an example.

     

    Thanks,

     

    Kyle

    Saturday, October 25, 2008 3:14 PM

Answers

  •  Kyle J. wrote:

    I mainly write code in C# & VB.NET, however, I've been asked to create a "console application" in FoxPro 8.  Is this possible?  Can someone point me to a "walk through" or an example.

    Kyle

     

    There is no such thing as a console application in VFP. Do you mean that you need to write an application with no UI? If this is the case, you just write the code in a .prg and run the .prg. If this isn't helpful, can you please give us more details about what you are trying to accomplish?

    Saturday, October 25, 2008 5:19 PM
  • To create a console application in Foxpro you need Foxpro for DOS (last version was 2.6). If you however mean an application with no UI then it is straight forward, do not create and show a window. ie:

     

    Code Snippet

    *main.prg

    * This is a very simple no UI application

    * It just checks for the existenced of a file

    * if exist opens and increases the values in a column by 1.15 and terminates

    if file('c:\MyFolder\myTable.dbf')

     update ('c:\MyFolder\myTable.dbf') set myField = myField * 1.15

    endif

     

     

    Looks like:

    Code Snippet

    using System.Data;

    using.System.Data.OleDb;

    using System.IO;

     

    class simple

    {

     static void Main() {

     if ( File.Exists("c:\MyFolder\myTable.dbf") ) {

       OleDbConnection con =

         new OleDbConnection(@"Provider=VFPOLEDB;Data Source =c:\MyFolder")';

       OleDbCommand cmd =

         new OleDbCommand("update myTable set myField = myField * 1.15", con);

       con.Open();

       cmd.ExecuteNonQuery();

       con.Close() }

     }

    }

     

     

    Sunday, October 26, 2008 3:47 PM

All replies

  •  Kyle J. wrote:

    I mainly write code in C# & VB.NET, however, I've been asked to create a "console application" in FoxPro 8.  Is this possible?  Can someone point me to a "walk through" or an example.

    Kyle

     

    There is no such thing as a console application in VFP. Do you mean that you need to write an application with no UI? If this is the case, you just write the code in a .prg and run the .prg. If this isn't helpful, can you please give us more details about what you are trying to accomplish?

    Saturday, October 25, 2008 5:19 PM
  • To create a console application in Foxpro you need Foxpro for DOS (last version was 2.6). If you however mean an application with no UI then it is straight forward, do not create and show a window. ie:

     

    Code Snippet

    *main.prg

    * This is a very simple no UI application

    * It just checks for the existenced of a file

    * if exist opens and increases the values in a column by 1.15 and terminates

    if file('c:\MyFolder\myTable.dbf')

     update ('c:\MyFolder\myTable.dbf') set myField = myField * 1.15

    endif

     

     

    Looks like:

    Code Snippet

    using System.Data;

    using.System.Data.OleDb;

    using System.IO;

     

    class simple

    {

     static void Main() {

     if ( File.Exists("c:\MyFolder\myTable.dbf") ) {

       OleDbConnection con =

         new OleDbConnection(@"Provider=VFPOLEDB;Data Source =c:\MyFolder")';

       OleDbCommand cmd =

         new OleDbCommand("update myTable set myField = myField * 1.15", con);

       con.Open();

       cmd.ExecuteNonQuery();

       con.Close() }

     }

    }

     

     

    Sunday, October 26, 2008 3:47 PM