Useful FoxPro commands

Visual FoxPro is a large and mature language with a wide choice of commands and functions. Many were introduced in earlier versions of the language and the older syntax has been carried all the way through from FoxBase to VFP.

This backwards compatibility means that it can sometimes be difficult to find just what you want in the Help system when you are first learning the language. Here is a list of some of the more useful commands and functions to get you started.

The technical distinction between commands and functions is that commands do something whereas functions just return a value to be displayed or used in another command.

General commands

CLEAR Clears the screen
CLEAR MEMORY Clears variables from memory
CLOSE DATA ALL Closes all tables and databases
QUIT Closes FoxPro

Files and directories

CD <dir> make <dir> the current directory.
CD ? display a directory tree and switch to the directory chosen.
SET PATH TO <path> force FoxPro to search for files along the path(s) specified.
GETDIR() display a directory tree and returns the directory name as a string.
GETFILE() displays a file-selection dialog and returns the file name as a string.

Miscellaneous

EMPTY(<name>) return .T. if field or variable <name> is empty.
GETCOLOR() display a colour picker and return the code for the colour chosen.
GETFONT() display a dialog listing all the fonts available and returns the name of the chosen font as a string.
GETPICT() display a file-selection dialog showing image files and returns the file name as a string.
ISNULL(<name>) return .T. if field or variable <name> is a null.
TYPE(<name>) return a code showing whether <name> is numeric, text, etc.