<

What is Microsoft Visual FoxPro?

Published on
16,852 Points
9,652 Views
2 Endorsements
Last Modified:
Approved
Olaf Doschke
Self-employed fullstack developer with backend preferences.
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express).

Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx
FAQ: http://msdn.microsoft.com/en-us/vfoxpro/bb190289

As in many other MS pogramming languages the "Visual" does not denote a visual programming language in the strict meaning of the term, but a visual programming  environment with visual form designers. Before FoxPro was bought by Microsoft and upgraded to Visual Foxpro, there was FoxPro DOS and also UNIX and MAC versions, the DOS version was mainly used, and so UNIX and MAC versions were dropped. The added "Visual" mainly denotes VFP has a visual IDE and supports Windows UI. This is still limited to Winforms, WPF or Silverlight are a DotNet exclusive.


Does It Pay To Begin With VFP?

VFP was discontinued in 2007, also VFP is in the last support phase of the Microsoft support lifecycle - called extended support - which ends January 2015. Microsoft doesn't sell VFP anymore, mainly because it would then need to make warranties exceeding that end of support date.

Microsoft rather recommends to take a look at VS Lightswitch 2011. I don’t agree, as this does not give a comparable experience, neither for VFP developers nor newbies. It integrates into the full VS, but itself rather is aimed for application generation by wizards and assistants and templates than for development of larger scale applications. It partly covers, what VFP also offers, as VFP also has wizards and builders, but you better cope without them.

What I agree is, VFP is not a language you should begin learning anymore, despite needing it to convert and migrate it. VFP has grown from the eighties to 2006, not resulting in an elegant overall architecture. It's having a steep learning curve for that matter and for not being very compact and lightweight. The steep learning curve also goes for DotNet but obviously pays more due to it's future perspectives. You can make up for this using third party application frameworks, which will make you more productive, but less learning VFP than the framework architecture. And of course there is a helpful community mentoring and helping you to go in the right directions, if you still choose to learn VFP. But the same options go for DotNet, too, again.

As a developer newbie wanting to do a databased application, either go Access for really small apps, for which you can live without OOP classes, etc, or go for the real deal VS.NET - even just the Express versions offer a good consistent architecture.

For VFP developers, though, which have not yet migrated and extended their know how, VFP is still a good tool to create and maintain small to medium size database applications with a magnitude of 100 users and even better scalable, when using an SQL Server as backend database instead of native database files.

The FoxPro community is still rather active for being 5 years past discontinuation and a VFPX project formed on Codeplex around Sedna extensions generously released by Microsoft to the public domain, which were developed so far in the aim of VFP 10.
And besides this, VFP developers of course look for successors of VFP, which is the topic of the final section of this article.


The Database in short

VFP tables are royalty free and have a per file limit of 2GB. By this definition a database has no overall size limit, but you need to watch your fastest growing tables and either archive or split data.

Backup and Restore can obviously be done on the file level, any backup software can be used, ideally off-hours, or choose something with a snapshot feature.

VFP is no database server, every client directly accesses the table files, even if you introduce a so called database container (DBC), this merely is a lookup table itself containing some meta data info about the tables belonging to the database, eg their file names. It also contains stored procs (including DML triggers) and dbc events (DDL triggers). Both types of triggers can make use of the full VFP language.

VFP data also supports transactions, which work without an sql server and are communicated to other clients by making use of several file lock types. Manual table and row locks also enable you to do manual locking and VFP also offers buffering of changes instead of or additional to transactions. VFP transactions only conform to three ACID properties Atomicity, Consistency and Isolation, but not to Durability. No transaction logs are written, in case of a system failure, the result is loss of transactional data, meaning a roll back to the pre transaction state. At least that's making transactions fail gracefully. The same goes for buffered changes.

Like Access, VFP can also link to external databases via ODBC drivers or OLEDB Providers.


The Programming language in short

The programming language rather compares to Visual Basic language and supports both procedural and OOP programming styles. It's dynamically typed, still data is strongly typed and functions and expressions are strongly typed and won't do but a few implicit type conversions of numeric types.

Like Java, VFP is compiled into object code consisting of tokenized byte code. These byte tokens are run by the vfp runtime, which does no further just in time compilation on the specific cpu architecture an exe or dll runs. This makes VFP an interpreter with a precompiler rather than a compiler language, still you compile to EXE and DLL and need nothing but Windows and the runtimes to run a VFP executable.

You can create n-tier applications with VFP by it's OOP nature and COM support.


Pros and Cons

Pros

VFP is OOP, it offers not as much oop features as DotNet, but much more than Access with it's class modules. VFP offers the most important of course: inheritance. It also supports private and hidden methods or properties, but no interfaces and no events can be user generated.
VFP is very resource friendly, yet quite capable in working on several GB data (comparable to SQL Express or LocalDB). The VFP9 IDE can be used in Win2k or later and created EXEs can be used in Win98 or later.
VFP databases are royalty free, no CALs nor CPU licenses are needed.
VFP has SQL built in, it's part of the language, not seperate command strings you send to databases. It compiles and verifies at that stage.
VFP offers a feature of macro substitution, which means single line code generated and compiled at runtime, but even COMPILE is a command the runtime supports.
Interoperability end Extensibility: VFP supports ODBC and COM/OLE and is capable to connect to remote databases, do OLE automation of office applications and any other OLE automatable applications besides of course parameterized command line calls to other executables. You can also make use of COM DLLs and stdcall function DLLs. The latter in a special form of FLLs can also expand the instruction set with Functions.
VFP supports Webservices, eg via Soap Toolkit or third party XML Tools, both as server or client, and if you just use MS COM XML parsers and serialisers.
VFP can build COM Server DLLs, including multithreaded DLLs. These also can form the base of web services, which can be published via the Soap Toolkit or manually via DCOM/COM+ in IIS, some third party extensions bring VFP to the web this way.

Cons

Unicode support is very limited to a few string functions for conversion, the OS API offers more, there is no native control to display Unicode, but VFP supports ActiveX controls. VFP-Tables are generally coed in ANSI code pages including support of fontcharsets/scripts, which means double byte ANSI charsets. There are no Unicode field types, too, but binary field types can store anything, including Unicode texts, of course.
Security: VFP Databases can be encrypted using third party tools or the Windows Crypto API, but access rights or roles on the data have to be implemented on the NTFS file access permissions level.
Stability: DBFs have a bad reputation to often become defect. So do MDBs. Proper used, this is just partially correct. The most often header defect can be repaired with native VFP code, and there are third party tools to repair tables and related files. In single user mode on local HDDs, FoxPro databases are usable maintenance free, as most all defects have their root in concurrent file access and network errors, which then of course don't occur.

Size limitations: As already discussed, there is no overall limit but a per 2GB per file limit.


Successors of VFP

There are quite a bunch of candidates aiming towards VFP developers, who look for new directions. There are four main categories:

1.

Languages, which - like VFP - evolved from the original dBase or Clipper, namely xBase++ and xHarbour.

2.

VFP itself and it’s community extensions, namely VFPX at Codeplex and some more side projects

3.

Some cloud based alternatives, from which FoxInCloud is stongly Foxpro based, not aiming for migration of the language but just the infrastructure. The same goes for ActiveVFP and VFP2IIS. Lianja supports Fox as one language and Servoy, which aims for Javascript developers and is Java based itself.

4.

Efforts to reimplement Foxpro, which include Guineu (a DotNet based VFP Runtime, bringing VFP to Windows Mobile or other DotNet Framework supported platforms, VFPCompiler for .NET compiling Foxpro code as .NET apps and assemblies and Visual FreePro, as a new candidate in that range.I don’t mention Java and DotNet as successors, because they are a league of their own. They surely are a big option not neglectible but aside of the feature shrinked Lightswitch don’t aim for VFP developers. For professionals they are of course enabling you to go further into the enterprise league.


Database Migration

VFP Data can be easily converted and upsized to any server database from MySQL up to Oracle. As mentioned, VFP can make use of ODBC drivers and OLEDB Providers, opening the full range of third party databases. Surely MS SQL Server is one good new home of VFP data.

There is much more to say about this, for example it’s getting more complex, if the VFP database also has stored procedures, we’re back on the topic of migrating application code.

Still aside of stored procedures migration one thing to mention here is Sybase Advantage Database Server, which offers a newer 32bit and 64bit ODBC driver also usable for native VFP9 data, as long as no stored procs are involved.
2
Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free