Visual FoxPro
Visual FoxPro is a data-centric, object-oriented,
procedural, programming language produced by
Microsoft. It is derived from FoxPro (originally known
as FoxBASE) which was developed by Fox Software
beginning in 1984. It contained the fastest PC-based
database engine available at the time. Fox Technologies
merged with Microsoft in 1992, after which the software
acquired further features and the prex Visual. The
database engine became known as the Microsoft Jet
Database Engine which was used by Microsoft Access.
The last version, (FoxPro 2.6) worked on Mac OS,
DOS, Windows, and Unix: Visual FoxPro 3.0, the rst
Visual version, reduced platform support to only Mac
and Windows, and later versions 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.
the rst time. In June 2006 it peaked at position 12, making it (at the time) a B language. By September 2010,
FoxPro and its variants had fallen out of the top 50, where
it has remained ever since.
In March 2007, Microsoft announced that there will be no
VFP 10,[8] thus making VFP9 (released to manufacturing
on December 17, 2004) the last commercial VFP release
from Microsoft. The support of Version 9 is ongoing with
service packs that were released December 8, 2005 and
October 11, 2007.
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,
Version 9.0, released in 2004 and updated in 2007, is the .NET Framework, Windows Vista, Oce 2007, Winnal version of the product.
dows Search and Team Foundation Server (TFS). Microsoft released Sedna under the Shared source license on
the CodePlex site. Microsoft has claried that the VFP
core
will still remain closed source. Sedna was released
1 History
on January 25, 2008.[9] As of March 2008, all xBase
components of the VFP 9 SP2 (including Sedna) were
FoxPro originated as a member of the class of languages
available for community-development on CodePlex.
commonly referred to as xBase languages, which have
syntax based on the dBase programming language. Other In late March 2007 a grassroots campaign was
members of the xBase language family include Clipper started by the Spanish-speaking FoxPro community
and Recital. (A history of the early years of xBase can be at MasFoxPro[10] (MoreFoxPro in English) to sign a
petition to Microsoft to continue updating Visual FoxPro
found in the dBase article.)
or release it to the community as Open Source. On
Visual FoxPro, commonly abbreviated as VFP, is tightly
April 3, 2007 the movement was noted by the technical
integrated with its own relational database engine, which
press.[11]
extends FoxPros xBase capabilities to support SQL
query and data manipulation. Unlike most database Also on April 3, 2007 Microsoft responded to the petimanagement systems, Visual FoxPro is a full-featured, tioners requests with this statement from Alan Griver:[11]
dynamic programming language that does not require the
We're very aware of the FoxPro commuuse of an additional general-purpose programming envinity
and that played a large part in what we anronment. It can be used to write not just traditional "fat
nounced
on March 13th. Its never an easy declient" applications, but also middleware and web applicision
to
announce that we're not going to recations.
lease another version of a product and its one
In late 2002, it was demonstrated that Visual FoxPro
that we consider very carefully.
can run on Linux under the Wine Windows compatibilWe're not announcing the end of FoxPro:
ity suite. In 2003, this led to complaints by Microsoft: it
Obviously, FoxPro applications will continue
was claimed that the deployment of runtime FoxPro code
to work. By some of our internal estimates,
on non-Windows machines violates the End User License
there are more applications running in FoxPro
Agreement.[6]
2.6 than there are in VFP and FoxPro 2.6 hasn't
Visual FoxPro had a rapid rise and fall in popularity as
been supported in many years. Visual FoxPro
measured by the TIOBE Programming Community In9 will be supported by Microsoft through 2015.
dex.[7] In December 2005, VFP broke into the top 20 for
For Microsoft to continue to evolve the
1
2
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.
1.1
Version Timeline
All versions listed are for Windows.[12]
Code samples
The FoxPro language contains commands quite similar
to other programming languages such as Basic. Loops
include do, if, while, for, else commands in a usage easily
understood by anyone familiar with other programming
languages. Commands take the form of command and
endcommand
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 ELSE i = i + 3 ENDIF x = 1 DO WHILE x < 50
x = x + 1 ENDDO x = 1 DO WHILE .T. x = x +
1 IF x < 50 LOOP ELSE EXIT ENDIF ENDDO
nMonth = MONTH(DATE()) DO CASE CASE
nMonth <= 3 MESSAGEBOX(Q1) CASE nMonth
<= 6 MESSAGEBOX(Q2) CASE nMonth <= 9
MESSAGEBOX(Q3) OTHERWISE MESSAGEBOX(Q4) ENDCASE FOR EACH oControl IN [Link] MESSAGEBOX([Link])
ENDFOR f = Factorial(10) FUNCTION Factorial(n)
LOCAL i, r && It is conventional to use lnI and lnR for
variables, rather than single digits r = 1 FOR i = n TO 1
STEP 1 r = r * n NEXT && Can also use ENDFOR
here instead of NEXT RETURN r ENDFUNC
Hello World example:
* Version 1: MESSAGEBOX(Hello World) * Version
2: ? Hello World
CODE SAMPLES
Output of the Hello World program.
2.1 Object
loForm
=
CREATEOBJECT(HiForm)
[Link](1) DEFINE CLASS HiForm AS Form
AutoCenter = .T. Caption = Hello, World ADD
OBJECT lblHi as Label ; WITH Caption = Hello,
World!" ENDDEFINE
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
its hidden externally. ? loMine.MyMethod1() &&
This will work. ? loMine.MyMethod2() && Program
Error: Property MYMETHOD2 is not found because
its hidden externally.
DEFINE CLASS MyClass
AS Custom 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 ENDIF 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 ENDDEFINE
VFP has an extensive library of predened classes
and visual objects which are accessed in the IDE by
a Property Sheet (including Methods),[13] so code
such as the above dening classes and objects are
only needed for special purposes and the framework
of large systems.
2.2
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.
&& To close the connection ENDIF * 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
ENDIF * If we get here, we have retrieved everything
successfully EXIT && Exit unconditionally ENDDO *
Close the connection SQLDISCONNECT(nHnd)
3 References
[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] A Message to the Community. Visual FoxPro Developer
Center. Microsoft. Retrieved 7 June 2013.
Output of the Data handling program.
[4] System Requirements. Visual FoxPro Developer Center.
Microsoft. Retrieved 7 June 2013.
* Create a table CREATE TABLE randData (iData
I) * Populate with random data using xBase and SQL [5]
DML commands FOR i = 1 TO 50 APPEND BLANK
REPLACE iData WITH (RAND() * 100) INSERT
INTO randData (iData) VALUES (RAND() * 100) [6]
ENDFOR * Place a structural index on the data INDEX
ON iData TAG iData CLOSE ALL * Display ordered [7]
data using xBase-style commands USE randData SET
ORDER TO iData GO TOP LIST NEXT 10 && First [8]
10 GO BOTTOM SKIP 10 LIST REST && Last 10
CLOSE ALL * Browse ordered data using SQL DML [9]
commands SELECT * ; FROM randData ; ORDER BY [10]
iData DESCENDING
Frequently Asked Questions. Visual FoxPro Developer
Center. Microsoft. Retrieved 7 June 2013.
Visual FoxPro for Linux: A Violation of the EULA?, May
13, 2003, By Ed Leafe, Linux Journal
Tiobe Index History for FoxPro
A Message to the Community
Microsoft SEDNA download
MasFoxPro
[11] Developers petition Microsoft to reconsider FoxPro phase
out --Broken Link-- Posted by Mary Jo Foley (April 3rd,
2007) - All about Microsoft - [Link]
2.3
ODBC access using SQL passthrough
[12] The History of FoxPro
PRIVATE cAuthorID, cAuthorName && Private [13] Visual FoxPro Development Productivity Tools. Mivariables supplant any previous global or private variable
crosoft. Retrieved 20 December 2014.
of the same name LOCAL nHnd, nResult && Local
variables are visible only here * Connect to an ODBC
data source nHnd = SQLCONNECT (ODBCDSN, 4 External links
user, pwd) * Enter a loop so we can exit to the
close connection code if theres an error DO WHILE
.T. * Execute a SQL command nResult = SQLEXEC 4.1 Microsoft pages
(nHnd, USE master) IF nResult < 0 MESSAGEBOX
Main Visual FoxPro Microsoft page
(MASTER database does not exist!") EXIT && To
close the connection ENDIF * Retrieve data from the
MSDN FoxPro support board
remote server and stores it in a local data cursor nResult
= SQLEXEC (nHnd, SELECT * FROM authors,
VFPs online help
QAUTHORS) IF nResult < 0 MESSAGEBOX (Un Visual FoxPro Downloads page
able to execute remote SQL SELECT command!") EXIT
4.2
Other pages
Visual FoxPro Wiki A repository of FoxPro information (written in VFP)
A site devoted to the history of FoxPro
VFPx A Visual FoxPro Community eort to create
open source add-ons for VFP 9.0
PortalFox A Hispanoamerican Community Portal
for VFP developers
EXTERNAL LINKS
Text and image sources, contributors, and licenses
5.1
Text
Visual FoxPro Source: [Link] Contributors: AxelBoldt, Andre Engels, Maury
Markowitz, Modster, Eurleif, StevenBlack, Rboatright, Mxn, Greenrd, Wik, Shizhao, Topbanana, Robbot, RedWolf, Alexf, SarekOfVulcan, Waza, Safety Cap, Tier, Grstain, Ta bu shi da yu, HedgeHog, Imroy, Rich Farmbrough, Lovelac7, Halleyscomet, Wikiacc, Danakil,
JesseHogan, WideArc, Stovetopcookies, Jeltz, Mikenolte, Mathmo, Pol098, Ruud Koot, Marudubshinki, Kesla, RyanNerd, Gudeldar,
Andrzej P. Wozniak, FlaBot, Introvert, Chobot, Bgwhite, Jasabella, YurikBot, Albanaco, RussBot, Thalter, Mikeblas, EEMIV, Brat32,
GraemeL, Funke, SmackBot, [Link], Thumperward, Captain Trips, DHN-bot, William Allen Simpson, Audriusa, GeorgeMoney,
Kentcurtis, Wizardman, Rexmorgan, JzG, Kuru, Ekjon Lok, Soumyasch, Balrog, Norm mit, Stevesawyer, Galaad2, Mellery, Hilmarz,
CRGreathouse, CmdrObot, Ale jrb, CBM, Charvex, Pro bug catcher, Cydebot, Notinthisworld, Fazilati, Thijs!bot, Zaiken, Gioto, Luna
Santin, Rsocol, Vespina, Samt3, Magioladitis, Dkalweit, Jvhertum, ArmadilloFromHell, Cander0000, AnimalFriend, Rrabins, EdBever,
Mmerlinn, BillWSmithJr, Icseaturtles, CraigBailey, Jutiphan, Gombang, D A Patriarche, Aivosto, Ubzy, Aspnetajax, Rei-bot, Mark Miller,
Nazgul02, Notbyworks, Jazz2013, Kawasemi, SieBot, Ryan2845, Phe-bot, JCLately, Elwhitney, OKBot, Recital, TheCatalyst31, ClueBot,
Bigown, Blanchardb, Auntof6, Mikaey, Mlas, Thingg, DumZiBoT, Avoided, Addbot, ToolmakerSteve, Mortense, Lexie 40, Download, Amirobot, ToddClausen, AnomieBOT, VX, Haggisbingo, Abhkum, TamarGranor, Igor2004, FrescoBot, Surv1v4l1st, Cdw1952,
Rob smith 06, DrilBot, MastiBot, Full-date unlinking bot, Ericsalim, WikitanvirBot, Wikipelli, Kypr8, ClueBot NG, [Link], Widr,
BG19bot, VictorEspina, Codename Lisa, Edleafe, Larryq34, Joshuamai and Anonymous: 210
5.2
Images
File:Folder_Hexagonal_Icon.svg Source: [Link] License: Cc-bysa-3.0 Contributors: ? Original artist: ?
File:Symbol_list_class.svg Source: [Link] License: Public domain Contributors: ? Original artist: ?
File:Symbol_neutral_vote.svg Source: [Link] License: Public domain
Contributors: ? Original artist: ?
File:[Link] Source: [Link] License: Fair use Contributors:
self-made
Original artist: ?
File:[Link] Source: [Link] License: Fair use Contributors:
Self-created
Original artist: ?
File:[Link] Source: [Link] License: Fair
use Contributors:
Self-created
Original artist: ?
5.3
Content license
Creative Commons Attribution-Share Alike 3.0