Visual FoxPro

Print Print
Reading time 10:48

Visual FoxPro
Visual FoxPro v9 running on Windows XP
Final release
v9.0 SP2[1] / October 16, 2007; 13 years ago (2007-10-16)[2]
Operating systemWindows 2000, Windows XP, and Windows Server 2003[3]
Available inIDE: English, German, Spanish
Runtime: Above plus French, Chinese, Russian, Czech, Korean
TypeIntegrated development environment, programming language
LicenseCommercial proprietary software

Visual FoxPro was a Microsoft data-centric procedural programming language that subsequently became object-oriented.

It was derived from FoxPro (originally known as FoxBASE) which was developed by Fox Software beginning in 1984. Fox Technologies merged with Microsoft in 1992, after which the software acquired further features and the prefix "Visual".[6]FoxPro 2.6 worked on Mac OS, DOS, Windows, and Unix.

Visual FoxPro 3.0, the first "Visual" version, reduced platform support to only Mac[7] and Windows, and later versions 5, 6, 7, 8 and 9 were Windows-only. The current version of Visual FoxPro is COM-based and Microsoft has stated that they do not intend to create a Microsoft .NET version.

Version 9.0, released in December 2004 and updated in October 2007 with the SP2 patch, was the final version of the product.


Visual FoxPro originated as a member of the class of languages commonly referred to as "xBase" languages, which have syntax based on the dBase programming language. Other members of the xBase language family include Clipper and Recital (database).

Visual FoxPro, commonly abbreviated as VFP, is tightly integrated with its own relational database engine, which extends FoxPro's xBase capabilities to support SQL query and data manipulation. Unlike most database management systems, Visual FoxPro is a full-featured, dynamic programming language that does not require the use of an additional general-purpose programming environment. It can be used to write not just traditional "fat client" applications, but also middleware and web applications.

In late 2002, it was demonstrated that Visual FoxPro can run on Linux under the Wine Windows compatibility suite. In 2003, this led to complaints by Microsoft: it was claimed that the deployment of runtime FoxPro code on non-Windows machines violates the End User License Agreement.[8]

Visual FoxPro had a rapid rise and fall in popularity as measured by the TIOBE Programming Community Index.[9] In December 2005, VFP broke into the top 20 for the first time. In June 2006 it peaked at position 12, making it (at the time) a "B" language. As of October 2019, Visual FoxPro holds position 51 on the TIOBE index.[10]

In March 2007, Microsoft announced that there will be no VFP 10,[11] thus making VFP9 (released to manufacturing on December 17, 2004) the last commercial VFP release from Microsoft. Service Pack 2 for Microsoft Visual FoxPro 9.0 was released on October 16, 2007.[12] The support of Version 9 ended on January 13, 2015.[13]

At the time of the end of life announcement, work on the next release codenamed Sedna (named after a recently discovered dwarf planet) which was built on top of the VFP9 codebase had already begun. "Sedna" is a set of add-ons to VFP 9.0 of xBase components to support a number of interoperability scenarios with various Microsoft technologies including SQL Server 2005, .NET Framework, Windows Vista, Office 2007, Windows Search and Team Foundation Server (TFS). Microsoft released Sedna under the Shared source license on the CodePlex site. Microsoft has clarified that the VFP core will still remain closed source. Sedna was released on January 25, 2008.[14] As of March 2008, all xBase components of the VFP 9 SP2 (including Sedna) were available for community-development on CodePlex.

In late March 2007 a grassroots campaign was started by the Spanish-speaking FoxPro community at MásFoxPro[15] ("MoreFoxPro" in English) to sign a petition to Microsoft to continue updating Visual FoxPro or release it to the community as open-source. On April 3, 2007 the movement was noted by the technical press.[16]

On April 3, 2007, Microsoft responded to the petition with this statement from Alan Griver:[16]

"We're very aware of the FoxPro community and that played a large part in what we announced on March 13th. It's never an easy decision to announce that we're not going to release another version of a product and it's one that we consider very carefully.

"We're not announcing the end of FoxPro: Obviously, FoxPro applications will continue to work. By some of our internal estimates, there are more applications running in FoxPro 2.6 than there are in VFP and FoxPro 2.6 hasn't been supported in many years. Visual FoxPro 9 will be supported by Microsoft through 2015.

"For Microsoft to continue to evolve the FoxPro base, we would need to look at creating a 64-bit development environment and that would involve an almost complete rewrite of the core product. We've also invested in creating a scalable database with SQL Server, including the freely available SQL Server Express Edition. As far as forming a partnership with a third-party is concerned, we've heard from a number of large FoxPro customers that this would make it impossible for them to continue to use FoxPro since it would no longer be from an approved vendor. We felt that putting the environment into open source on CodePlex, which balances the needs of both the community and the large customers, was the best path forward."

Version Timeline

All versions listed are for Windows.[17]

Version Release Date
Visual FoxPro 3.0 June 1995
Visual FoxPro 5.0 October 1996
Visual FoxPro 5.0a October 1997
Visual FoxPro 6.0 18 May 1998
Visual FoxPro 7.0 27 June 2001
Visual FoxPro 8.0 1 February 2003
Visual FoxPro 8.0 Service Pack 1 7 October 2003
Visual FoxPro 9 20 December 2004
Visual FoxPro 9 Service Pack 1 8 December 2005
Visual FoxPro 9 Service Pack 2 16 October 2007

Code samples

The FoxPro language contains commands quite similar to other programming languages such as Basic.

Some basic syntax samples:

FOR i = 1 to 10
    x = x + 6.5
NEXT  && Instead of "NEXT" can also use "ENDFOR"

IF i = 25
    i = i + 1
    i = i + 3

x = 1
DO WHILE x < 50
    x =  x + 1

x = 1
    x = x + 1
    IF x < 50

nMonth = MONTH(DATE())
    CASE nMonth <= 3

    CASE nMonth <= 6

    CASE nMonth <= 9


FOR EACH oControl IN THISFORM.Controls

f = Factorial(10)

FUNCTION Factorial(n)
LOCAL i, r

    r = 1
    FOR i = n TO 1 STEP -1
        r = r * i
    NEXT  && Can also use "ENDFOR" here instead of "NEXT"
    RETURN r

Hello World examples:

 * Output at the current location
 ? "Hello World"

 * Output at a specified location
 @ 1,1 SAY "Hello World"

 * Output in a separate window, cleared on input
 WAIT WINDOW "Hello World"

 * Output in a standard dialog box, cleared on OK
 MESSAGEBOX("Hello World")


Output of the Hello World program.
* Output in a defined window
loForm = CREATEOBJECT("HiForm")

    AutoCenter   = .T.
    Caption      = "Hello, World"

    ADD OBJECT lblHi as Label ;
        WITH Caption = "Hello, World!"
loMine = CREATEOBJECT("MyClass")
? loMine.cProp1               && This will work. (Double-ampersand marks an end-of-line comment)
? loMine.cProp2               && Program Error: Property CPROP2 is not found because it's hidden externally.

? loMine.MyMethod1()          && This will work.
? loMine.MyMethod2()          && Program Error: Property MYMETHOD2 is not found because it's hidden externally.

    cProp1 = "My Property"    && This is a public property
    HIDDEN cProp2             && This is a private (hidden) property
    dProp3 = {}               && Another public property

    PROCEDURE Init()          && Class constructor
        This.cProp2 = "This is a hidden property."

    PROCEDURE dProp3_Access   && Property Getter
        RETURN DATE()

    PROCEDURE dProp3_Assign(vNewVal)     && Property Setter uses the "_assign" tag on the property name
        IF VARTYPE(vNewVal) = "D"
            THIS.dProp3 = vNewVal

    PROCEDURE MyMethod1()
    * This is a public method, calling a hidden method that returns
    * the value of a hidden property.
        RETURN This.MyMethod2()

    HIDDEN PROCEDURE MyMethod2()  && This is a private (hidden) method
        RETURN This.cProp2
  • VFP has an extensive library of predefined classes and visual objects which are accessed in the IDE by a Property Sheet (including Methods),[18] so code such as the above defining classes and objects are only needed for special purposes and the framework of large systems.

Data handling

The language also has extensive database manipulation and indexing commands. The "help" index of commands in VFP 9 has several hundred commands and functions described. The examples below show how to code the creation and indexing of tables, however VFP has table and database builder screens which create the tables and indexes without making you write code.

Output of the Data handling program.
 * Create a table
 CREATE TABLE randData (iData I)

 * Populate with random data using xBase and SQL DML commands
 FOR i = 1 TO 50
     REPLACE iData WITH (RAND() * 100)

     INSERT INTO randData (iData) VALUES (RAND() * 100)

 * Place a structural index on the data
 INDEX ON iData TAG iData
 CLOSE DATA       && Do not close open libraries etc

 * Display ordered data using xBase-style commands
 USE randData
 LOCATE           && In place of GO TOP. Enforces use of index to find TOP  
 LIST NEXT 10     && First 10
 SKIP -10
 LIST REST        && Last 10

 * Browse ordered data using SQL DML commands
   FROM randData ;

ODBC access using SQL passthrough

 PRIVATE cAuthorID, cAuthorName      && Private variables supplant any previous global or private variable of the same name
 LOCAL nHnd, nResult                 && Local variables are visible only here

 * Connect to an ODBC data source
 nHnd = SQLCONNECT ("ODBCDSN", "user", "pwd")

 * Enter a loop so we can exit to the close connection code if there's an error
     * Execute a SQL command
     nResult = SQLEXEC (nHnd, "USE master")
     IF nResult < 0
         MESSAGEBOX ("MASTER database does not exist!")
         EXIT  && To close the connection

     * Retrieve data from the remote server and stores it in a local data cursor
     nResult = SQLEXEC (nHnd, "SELECT * FROM authors", "QAUTHORS")
     IF nResult < 0
         MESSAGEBOX ("Unable to execute remote SQL SELECT command!")
         EXIT  && To close the connection

     * Update a record in a remote table using parameters
     cAuthorID     = "1001"
     cAuthorName   = "New name"
     nResult       = SQLEXEC (nHnd, "UPDATE authors SET auth_name = ?cAuthorName WHERE auth_id = ?cAuthorID")
     IF nResult < 0
         MESSAGEBOX ("Unable to execute remote SQL UPDATE command!")
         EXIT  && To close the connection

     * If we get here, we have retrieved everything successfully
     EXIT  && Exit unconditionally

 * Close the connection


Some notable applications written in Visual FoxPro include

  • PWCT: free open source visual programming language for software development

See also


  1. ^ "Visual FoxPro 9.0 Updates". Visual FoxPro Developer Center. Microsoft. Retrieved 7 June 2013.
  2. ^ "Download Microsoft Visual FoxPro 9.0 Service Pack 2.0". Download Center. Microsoft. October 16, 2007. Retrieved 7 June 2013.
  3. ^ "System Requirements". Visual FoxPro Developer Center. Microsoft. Retrieved 7 June 2013.
  4. ^ "Frequently Asked Questions". Visual FoxPro Developer Center. Microsoft. Retrieved 7 June 2013.
  5. ^ "A Message to the Community". Visual FoxPro Developer Center. Microsoft. Retrieved 7 June 2013.
  6. ^ NY Times
  7. ^ Microsoft Visual FoxPro 3.0 for Power Macintosh Now Available, July 25, 1996,
  8. ^ Visual FoxPro for Linux: A Violation of the EULA?, May 13, 2003, By Ed Leafe, Linux Journal
  9. ^ Tiobe Index History for FoxPro
  10. ^
  11. ^ A Message to the Community
  12. ^ Microsoft Visual FoxPro 9.0 Service Pack 2.0
  13. ^ "Microsoft Visual FoxPro 9.0 Lifecycle". Retrieved 2018-08-31.
  14. ^ Microsoft SEDNA download
  15. ^ Mas FoxPro - Visual FoxPro Wiki
  16. ^ a b Developers petition Microsoft to reconsider FoxPro phase out Posted by Mary Jo Foley (April 3rd, 2007) - All about Microsoft -
  17. ^ The History of FoxPro
  18. ^ "Visual FoxPro Development Productivity Tools". Microsoft. Retrieved 20 December 2014.

External links

Microsoft pages

Other pages

Edited: 2021-06-18 18:21:49