Difference between revisions of "Visual FoxPro"

From TheAlmightyGuru
Jump to: navigation, search
(Quirks)
(Review)
(43 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Image:Visual FoxPro 9.jpg|thumb|256x256px|Visual FoxPro 9.]]
 
[[Image:Visual FoxPro 9.jpg|thumb|256x256px|Visual FoxPro 9.]]
  
'''''Visual FoxPro''''', or '''''VFP''''', is a programming language and IDE from [[Microsoft]]. The primary use of the language is for rapid database application development. The programming syntax is similar to that of [[Visual BASIC]] (not [[VB.NET]]). The language uses dynamic inferred structural typing. It compiles to pseudo-code which is interpreted by the runtimes which must be distributed along with the program.
+
'''Visual FoxPro''', or '''VFP''', is a [[Computer programming|programming language]] and [[integrated development environment|IDE]] that was sold by [[Microsoft]], but is now defunct. The primary use of the language is for rapid database application development. The programming syntax is similar to that of [[Visual Basic]] (not [[VB.NET]]). The language uses dynamic inferred structural typing. It compiles to pseudo-code which is interpreted by the runtimes which must be distributed along with the program.
  
Visual FoxPro is based off of [[FoxPro]], which was the result of Microsoft buying FoxBase from [[Fox Software]]. FoxBase was derived from dBase III.
+
Visual FoxPro is based off of [[FoxPro]], which was the result of Microsoft buying FoxBase from Fox Software. FoxBase was derived from dBase III. The last official release of Visual FoxPro was version 9, which was released in 2004 with a final service pack released in 2007. Microsoft officially discontinued support in 2015, most likely because it was taking away sales of from SQL Server, which was more popular (and expensive).
  
The last official release of Visual FoxPro was version 9, which was released in 2004 with a final service pack released in 2007. Microsoft officially discontinued support in 2015.
+
==Personal==
 
+
Though I had seen FoxPro icons since my first days with [[Windows 3]], I never knew what FoxPro was. I got my first taste of Visual FoxPro in 1999 because it was the main programming language used by the company I started working for. I was familiar with Visual Basic, so it was pretty easy for me to pickup the syntax, and I had just developed an [[Access]] application for my high school, so I knew enough about databases to secure my job. I've used VFP from version 6 until its final release, version 9.0 SP2.
Though I had seen FoxPro icons since my first days with [[Windows 3]], I never knew what FoxPro was. I got my first taste of Visual FoxPro in 1999 because it was the main programming language used by the company I started working for. I was familiar with Visual BASIC, so it was pretty easy for me to pickup the syntax, and I had just developed an Access application for my high school, so I knew enough about databases to secure my job. I've used VFP from version 6 until its final release, version 9.0 SP2.
 
  
 
==Review==
 
==Review==
 
===Good===
 
===Good===
* The language has a built-in database creator, editor, and viewer. Though it's not without its problems, it's the best I've ever worked with.
+
* The language has the best querying abilities I've seen in any language. You can quickly and easily query data then keep the results around for as long as you need them and easily re-query them.
* It has a full [[SQL]] interpreter as well as many additional database features not found even in modern databases, and they're very easy to use.
+
* The IDE has a bunch of built-in editors for databases, forms, reports, menus, and more. Though none of them aren't without their problems, it's one of the most complete I've ever used.
* The SQL speed is lightning fast, even to the point of outpacing SQL Server at times since it doesn't have built-in transaction logging.
+
* The IDE uses a vastly superior MDI (multiple document interface) instead of the inferior, and, unfortunately, now industry-standard, TDI (tabbed document interface). Unlike in a TDI, you can easily open and view several different code segments and designers at the same time and put them anywhere on your screen you like. You can even open multiple widows from the same code source which is extremely helpful, something I wish every other IDE would adopt (I'm looking at you [[Visual Studio]]!).
* The IDE uses a wonderful multi-window system so you can easily open and view several different code blocks at the same time, even from the same object, something I wish Visual Studio would adopt.
+
* It has a full [[Structured Query Language|SQL]] interpreter which is compatible with the entire VFP command syntax pushing it well-beyond what SQL is capable of.
 +
* Database access is lightning fast and highly optimized, even to the point of outpacing many other professional SQL implementations.
 
* Some of the table field types are quite useful like the currency with 4-digit decimal precision, and the numeric which is based on length of digits rather than bytes.
 
* Some of the table field types are quite useful like the currency with 4-digit decimal precision, and the numeric which is based on length of digits rather than bytes.
* Unlike most earlier versions of Visual BASIC, VFP had several built-in variable types like datetime and logical.
+
* Unlike most earlier versions of [[Visual Basic]], VFP had several built-in variable types like datetime and logical with assorted functions to work with them.
 +
* VFP gives you full access to table statistics without having to query them. For example, if you want to know the number of records in an SQL table, you would generally issue "SELECT COUNT(*)" which requires counting every record in the table individually. However, in VFP, the record count is stored in the metadata of the table, so it doesn't require querying at all.
 +
* The language is [[case sensitivity|case-insenstive]].
  
 
===Bad===
 
===Bad===
* The database format is way out of date and doesn't support any modern formats like Unicode.
+
* The database format is way out of date and doesn't support Unicode. It has dual-byte character encoding based on ISO codepages, but it's very limited and difficult to implement.
* Numeric variables (and likewise, table fields) are divorced from most other languages. There is no support for unsigned values at all, and there are no primitive types like byte, int, long, etc. Instead, all numbers are treated as either signed double integers or floats, and even then, their type is implied.
+
* Numeric variables (and likewise, table fields) are divorced from most other languages. There is no support for unsigned values at all, and there are no primitive types like byte, int, long, etc. Instead, all numbers are treated as either signed double integers or floats, and even then, their type is always implied.
 
* Functions that affect file names like ''Copy File'' don't preserve text case.
 
* Functions that affect file names like ''Copy File'' don't preserve text case.
 
* The UI tries to remember the position of windows and the code block you last viewed, but usually fails.
 
* The UI tries to remember the position of windows and the code block you last viewed, but usually fails.
 
* Although VFP is mostly object oriented, it has a lot of legacy commands and functions that are procedural. This lack of standards creates confusion.
 
* Although VFP is mostly object oriented, it has a lot of legacy commands and functions that are procedural. This lack of standards creates confusion.
 
* While text fields longer than 254 characters are possible, they require the use of "memos" which are especially cumbersome to work with.
 
* While text fields longer than 254 characters are possible, they require the use of "memos" which are especially cumbersome to work with.
* VFP's help has a poor index which is missing dozens of commands. For example, Type "ALEN" in the Index tab and you get a page for "_ALen() API library routine," but there isn't an entry for the ALEN() Function, even though a page exists and can be found in the Search tab.
 
 
* VFP's help is seriously lacking on SQL examples and only shows you the most basic of queries.
 
* VFP's help is seriously lacking on SQL examples and only shows you the most basic of queries.
 +
* VFP's help has a poor index which is missing dozens of commands. For example, a SCAN...ENDSCAN is a very popular command, but, if you type "SCAN" into the index, you will only get a page for "SCAN loop exit." It is also missing indexes for ALEN. To find these pages, you have to use the Search tab in help.
  
 
===Ugly===
 
===Ugly===
 
* VFP has really poor ActiveX and OLE support, often to the point of crashing the UI.
 
* VFP has really poor ActiveX and OLE support, often to the point of crashing the UI.
* VFP has really poor array support and only supports 2D arrays (to resemble tables). Single dimensional arrays, or three or more dimensional arrays are not possible.
+
* VFP has really poor array support and only supports 2D arrays (to resemble tables). Single dimensional arrays and arrays with three or more dimensions are not possible.
 
 
==Quirks==
 
This is a list quirks found in VFP and how to resolve them.
 
 
 
===Dynamic Inferred Structural Typing===
 
It's refreshing to have a language intelligent enough to determine what type of variable you need based on how you assign it and not need to cast types every time it changes. For example, the following code will yield "1.1," but in a strong-typed language, you would need to declare the type of Integer as an int, Float as a float, Sum as a float, cast Integer into a float to add them, and then convert to a string to display them with MessaheBox.
 
 
 
Integer = 1
 
Float = 0.1
 
Sum = Integer + Float
 
MessageBox(Sum)
 
 
 
However, this allows for very sloppy code, for example, the following will run just fine:
 
 
 
String = "test"
 
String = 1
 
String = .T.
 
String = DateTime()
 
 
 
Not to mention, this prevents the compiler from identifying type-based errors at design time, so you get a lot of "Operator/operand type mismatch" errors during runtime. For example, the following code compiles just fine:
 
 
 
Integer = 1
 
String = "test"
 
Sum = Integer + String
 
 
 
===VFP Processes Fields Before Variables===
 
When reading or writing data, VFP tries to access table fields before memory variables. This can create unexpected results when you have a memory variable with the same name as field in the currently selected table. For example, in the following code, the MessageBox will read "Table Field" not "Memory Variable":
 
 
 
Create Cursor Test (Variable C(11))
 
Insert Into Test (Variable) Values ("Table Field")
 
Variable = "Memory Variable"
 
MessageBox(Variable)
 
 
 
To force VFP to read and write to a memory variable instead of a field, add "m." to the beginning of the variable. For example, in this code, the MessageBox will read "Memory Variable":
 
 
 
Create Cursor Test (Variable C(11))
 
Insert Into Test (Variable) Values ("Table Field")
 
m.Variable = "Memory Variable"
 
MessageBox(m.Variable)
 
 
 
Personally, I find it to be best practice to never give my variables names that might be used by fields. To guarantee this, I use Hungarian notation for memory variables, but not for fields.
 
 
 
===Brackets Are Used For Both Strings and Arrays===
 
Like Visual BASIC, VFP uses parentheses to call an array element, for example:
 
 
 
Local Array aTest(10, 2)
 
 
 
However, VFP also lets you use brackets like a C-based language:
 
 
 
Local Array aTest[10, 2]
 
 
 
But, to really complicate things, VFP also lets you use brackets for strings:
 
 
 
sString = [This is the contents of a string]
 
 
 
This confuses the color syntaxing of the interpreter, so when you use brackets to denote an element in an array, it is colored as though you're setting a value of a string.
 
 
 
===VarType Can't Identify Non-Existent Properties On Non-Existent Objects===
 
Because VFP uses the period operator for both table fields and object properties, it prevents VarType from being able to properly distinguish a table from a non-existent properties on non-existent objects. For example, in the following code, NotAnObject will properly be described with a "U" for undefined, the oForm.Visible property will be described with an "L" for logical, the oForm.NotAProperty non-existent property will be described with a "U," but the non-existent property on the non-existent object will throw an error of "Alias 'NOTANOBJECT' is not found," because VFP will assume it's a table because it has a period in it, and it's not an object.
 
 
 
MessageBox(VarType(NotAnObject))
 
oForm = CreateObject("Form")
 
MessageBox(VarType(oForm.Visible))
 
MessageBox(VarType(oForm.NotAProperty))
 
MessageBox(VarType(NotAnObject.NotAProperty))
 
 
 
You can get around this problem by using the Type command when you're not sure if the object will exist:
 
 
 
MessageBox(Type("NotAnObject.NotAProperty"))
 
  
===Sporadic Failures On One-Record Tables===
+
==Tricks==
My company found an extremely rare bug that occurs when you run a Locate command on a table with only one record. Even if Found() returns .T. and RecNo() returns 1, VFP is actually on End of File and will return an empty value for the requested field. This can be resolved by adding an additional blank record to that table.
+
* [[Visual FoxPro Tricks]]
  
 
==Links==
 
==Links==
* [http://en.wikipedia.org/wiki/Visual_Fox_Pro en.wikipedia.org/wiki/Visual_Fox_Pro] - Wikipedia.
+
{{Link|Wikipedia|http://en.wikipedia.org/wiki/Visual_Fox_Pro}}
  
  
 
[[Category: Software]]
 
[[Category: Software]]
 
[[Category: Programming Languages]]
 
[[Category: Programming Languages]]
 +
[[Category: Database Software]]
 +
[[Category: Integrated Development Environments]]
 +
[[Category: Windows Software]]
 +
[[Category: Windows 3 Software]]

Revision as of 15:03, 16 May 2022

Visual FoxPro 9.

Visual FoxPro, or VFP, is a programming language and IDE that was sold by Microsoft, but is now defunct. The primary use of the language is for rapid database application development. The programming syntax is similar to that of Visual Basic (not VB.NET). The language uses dynamic inferred structural typing. It compiles to pseudo-code which is interpreted by the runtimes which must be distributed along with the program.

Visual FoxPro is based off of FoxPro, which was the result of Microsoft buying FoxBase from Fox Software. FoxBase was derived from dBase III. The last official release of Visual FoxPro was version 9, which was released in 2004 with a final service pack released in 2007. Microsoft officially discontinued support in 2015, most likely because it was taking away sales of from SQL Server, which was more popular (and expensive).

Personal

Though I had seen FoxPro icons since my first days with Windows 3, I never knew what FoxPro was. I got my first taste of Visual FoxPro in 1999 because it was the main programming language used by the company I started working for. I was familiar with Visual Basic, so it was pretty easy for me to pickup the syntax, and I had just developed an Access application for my high school, so I knew enough about databases to secure my job. I've used VFP from version 6 until its final release, version 9.0 SP2.

Review

Good

  • The language has the best querying abilities I've seen in any language. You can quickly and easily query data then keep the results around for as long as you need them and easily re-query them.
  • The IDE has a bunch of built-in editors for databases, forms, reports, menus, and more. Though none of them aren't without their problems, it's one of the most complete I've ever used.
  • The IDE uses a vastly superior MDI (multiple document interface) instead of the inferior, and, unfortunately, now industry-standard, TDI (tabbed document interface). Unlike in a TDI, you can easily open and view several different code segments and designers at the same time and put them anywhere on your screen you like. You can even open multiple widows from the same code source which is extremely helpful, something I wish every other IDE would adopt (I'm looking at you Visual Studio!).
  • It has a full SQL interpreter which is compatible with the entire VFP command syntax pushing it well-beyond what SQL is capable of.
  • Database access is lightning fast and highly optimized, even to the point of outpacing many other professional SQL implementations.
  • Some of the table field types are quite useful like the currency with 4-digit decimal precision, and the numeric which is based on length of digits rather than bytes.
  • Unlike most earlier versions of Visual Basic, VFP had several built-in variable types like datetime and logical with assorted functions to work with them.
  • VFP gives you full access to table statistics without having to query them. For example, if you want to know the number of records in an SQL table, you would generally issue "SELECT COUNT(*)" which requires counting every record in the table individually. However, in VFP, the record count is stored in the metadata of the table, so it doesn't require querying at all.
  • The language is case-insenstive.

Bad

  • The database format is way out of date and doesn't support Unicode. It has dual-byte character encoding based on ISO codepages, but it's very limited and difficult to implement.
  • Numeric variables (and likewise, table fields) are divorced from most other languages. There is no support for unsigned values at all, and there are no primitive types like byte, int, long, etc. Instead, all numbers are treated as either signed double integers or floats, and even then, their type is always implied.
  • Functions that affect file names like Copy File don't preserve text case.
  • The UI tries to remember the position of windows and the code block you last viewed, but usually fails.
  • Although VFP is mostly object oriented, it has a lot of legacy commands and functions that are procedural. This lack of standards creates confusion.
  • While text fields longer than 254 characters are possible, they require the use of "memos" which are especially cumbersome to work with.
  • VFP's help is seriously lacking on SQL examples and only shows you the most basic of queries.
  • VFP's help has a poor index which is missing dozens of commands. For example, a SCAN...ENDSCAN is a very popular command, but, if you type "SCAN" into the index, you will only get a page for "SCAN loop exit." It is also missing indexes for ALEN. To find these pages, you have to use the Search tab in help.

Ugly

  • VFP has really poor ActiveX and OLE support, often to the point of crashing the UI.
  • VFP has really poor array support and only supports 2D arrays (to resemble tables). Single dimensional arrays and arrays with three or more dimensions are not possible.

Tricks

Links

Link-Wikipedia.png