Skip to main content.

Web Based Programming Tutorials

Homepage | Forum - Join the forum to discuss anything related to programming! | Programming Resources

Special Edition Using Visual FoxPro 6

Special Edition Using Visual FoxPro 6 -- Ch 1 - Quick Review of the Visual FoxPro Interface

Special Edition Using Visual FoxPro 6

Chapter 1

Quick Review of the Visual FoxPro Interface

Over the past several years, an increasing number of complex applications have been built with microcomputer database systems such as FoxPro. But even with the tools that these systems provide-such as screen and report generators, libraries, and project managers-the total time needed to complete many applications has increased. Furthermore, users want to access data stored in other formats, and not only on their own machines but also on central database servers. FoxPro has grown from a DOS-based Xbase language to a Visual GUI (Graphical User Interface) application development tool in just a few short years. With the arrival of Visual Studio, FoxPro became a member of the Microsoft family of products and a vital part of the application development community. The focus of Visual Studio is to provide the programming and database tools to develop software that is capable of all of the things mentioned previously.

Previous releases of FoxPro began to address these problems. Although progress was made, something was still missing until the introduction of object programming. Many products have experimented with various degrees of object programming. Some products provide fixed definition objects, and the programmer has to use them as they are or not at all; they have no mechanism to start from a base object definition and build on it. Many people refer to this type of programming as object-based, not object-oriented. In fact, object-oriented developers look for features such as inheritance, polymorphism, subclassing, and event programming. Within the past couple of years, several products that have many of those features have been released. The authors feel, however, that Visual FoxPro presents the best implementation of an object-oriented, Xbase-compatible, database programming language to date.

This chapter introduces many basic concepts to ensure that all readers start from the same level.

Getting FoxPro Up and Running

Assuming that you have Visual FoxPro 6 (VFP) installed on your machine, how do you start it? When VFP installs, it creates a new Windows group called Microsoft Visual FoxPro and/or installs Visual FoxPro in the Start menu. In Windows NT, this group appears in the Project Manager. Double-clicking the group icon opens the group window, revealing an icon named Microsoft Visual FoxPro 6. This icon represents the main program. In Windows 95, VFP installs a group (now called a folder) in the Programs menu of the Start button. By default, the program folder gets the name Microsoft Visual FoxPro. Clicking this option opens another menu level that shows the available programs installed with Visual FoxPro. These programs correspond to the programs shown in the Visual FoxPro group window of the Project Manager. Figure 1.1 shows the Windows 95 version of this screen. Click the menu item Microsoft Visual FoxPro 6 to start FoxPro.

Figure 1.1 : Open Visual FoxPro 6 by using the Microsoft Visual FoxPro menu in the Programs menu of the Start menu.

When you install Visual Studio, you have the option of installing several programs such as Visual Basic and Visual C++ as well as Visual FoxPro 6. Just as Office 97 is a suite of tools that perform certain functions such as word processing and creating and maintaining databases and spreadsheets, Visual Studio can be thought of as being a suite of programming tools. Most people install all the programs during the installation process or just a few, and you can elect to install whatever you want depending on your needs and interests. If you have the disk space, it is recommended that you install the complete package because you might need the other programs later. You can also purchase FoxPro 6 as a standalone product. This means that you can install the program without having to buy the entire Visual Studio package, which is expensive. The installation process as described above is pretty much the same in Windows 95 and Windows 98. The easiest way to install any software from Windows 95 and Windows 98 is to choose Start, Run and then give the location of the files you want to install.

The Windows 95 Explorer provides another common way to start FoxPro. Use the Explorer to open the directory that contains Visual FoxPro and choose VFP.EXE from the file list, as shown in Figure 1.2.

Figure 1.2 : Open Visual FoxPro 6 by selecting it from the file list in the Explorer.

If you use Visual FoxPro frequently, as I do, you might want to create a shortcut for it on your desktop. To do so, open Explorer as shown in Figure 1.2, but rather than double-click to start VFP, right-click and drag VFP.EXE from the Explorer onto the desktop. When you release the mouse button, a shortcut menu appears with the following options: Move Here, Copy Here, Create Shortcut(s) Here, and Cancel.

Choose Create Shortcut(s) Here to place an icon on your desktop that executes Visual FoxPro when it is clicked. Figure 1.3 shows the VFP shortcut in the process of being created.

Figure 1.3 : Create a shortcut on your desktop for Visual FoxPro 6.

There is another way to create a shortcut in Windows 95 and Windows 98. Move the mouse cursor over a blank area of the Windows screen (not on any icon) and click the right mouse button. A screen will pop up and from this choose New and then Shortcut. After you select Shortcut, you will be presented with a Create Shortcut dialog box with which you can tell the program where to find the .EXE file of the program you want to create a shortcut for. If you do not know that location, you can search for it using the Browse button.

Finally, you can also run FoxPro by choosing the Run option in the Start menu of Windows 95 or Windows 98. Simply enter the program's fully qualified name and click OK. (You also can use the Browse button to find the file if you do not know its fully qualified name.) Figure 1.4 shows the Run dialog box.

Figure 1.4 : Start Visual FoxPro 6 by using the Run dialog box from the Start menu of Windows 95.

You can even start Visual FoxPro by double-clicking any program file (.PRG) from within the Explorer, as long as you have associated the .PRG extension with the file VFP.EXE.

No matter how you start Visual FoxPro, it opens in its own main window as shown in Figure 1.5; it also automatically opens the Command window inside the main window. (You might see an introductory splash screen that includes options to create a new project; explore the sample applications; explore the online documentation; open an existing project; close the splash screen; and to never display the splash screen again. Because this feature adds just one more step before getting into VFP, most developers turn it off, so you might not see it.) FoxPro refers to the main window as the FoxPro desktop or the screen. Later, as you write code that sends output to the screen (such as a report), FoxPro writes it in this window. FoxPro cannot write directly to the Windows desktop.

Figure 1.5 : Visual FoxPro 6's desktop, or main screen, opens with the Command window active.

The Title Bar

The title bar across the top of the main window contains five objects. The first object from the left is the application icon. Clicking it with either mouse button displays the Control menu, which has commands that move and resize the screen. You can even close FoxPro from this menu.

Table 1.1 lists the options that are available from the Control menu.

Table 1.1  Control Menu Options
RestoreRestores window to preceding size after minimization or maximization.
MoveSelects the main FoxPro window and enables you to move it by using the keyboard cursor controls.
SizeSelects the main FoxPro window and enables you to resize it by using the keyboard cursor controls.
MinimizeReduces FoxPro to an icon.
MaximizeMaximizes the size of the main FoxPro window. When maximized, a window has no border.
CloseCloses FoxPro.

The title Microsoft Visual FoxPro appears left-justified in the title bar in Windows 95. You can easily personalize this title, however, just as you can any other property. There are three ways to change it. The old way is as follows:


And the new way is

_SCREEN.caption = 'Michael P. Antonovich'


_VFP.caption = 'Michael Antonovich'

You'll probably want to put your own name in these commands.

The colored portion of the title bar also has a few other functions. First, you can click and drag it to move the window. Double-clicking it alternately maximizes and restores the window to its original size.

Finally, in case you are wondering, FoxPro gets the default color scheme for this title bar and all other window elements from the Windows Control Panel. Windows 95 stores color selections in the Registry.

Several buttons appear at the right end of the title bar. In Windows 95, the first button shows a horizontal bar across the bottom of the icon. Pressing this button minimizes the application and docks it in the taskbar at the bottom of the screen. Visual FoxPro continues running when it is minimized. If you want to restore a minimized application, click its name in the taskbar. (Minimizing individual windows within Visual FoxPro docks the window title at the bottom of the Visual FoxPro desktop.)

In Windows 95, the second button in this group toggles between two buttons: Maximize and Restore. The button used to maximize the Visual FoxPro desktop or the current window looks like a single window; the Restore button looks like two cascaded windows.

Windows 95 also has a separate Close button on the right side of each window. Clicking this button, which contains an X, closes Visual FoxPro (or the current window when you are in application windows).

Be Careful Which Button You Click
Many objects that open in their own windows display a similar Close button. Clicking this button closes the object. The potential danger is that these controls often appear immediately below FoxPro's main Close button. Thus, you can easily click the wrong Close button. As a developer, you will find that restarting VFP after making this mistake several times during a session is a major annoyance.
One solution stores the following program in FoxPro's main directory:
* This program intercepts a double-click on FoxPro's main
* screen and prompts the user to confirm that they want
* to leave FoxPro.
* Store this program as \VFP\REALQUIT.PRG

  LOCAL lnMsgResult
  lnMsgResult = MESSAGEBOX('Do you really want to quit FoxPro?', ;
       20, 'Exit FoxPro')
  IF lnMsgResult = 6  && User selected YES button
Then, at the beginning of each session, type the following command to activate the accidental exit protection:
This routine runs not only when the user attempts to close Visual FoxPro directly, but also when the user attempts to close Windows without first closing FoxPro, or if the user includes the QUIT command in his or her program or types it in the Command window.
Rather than needing to remember to enter this command, consider adding it to the CONFIG.FPW file as a startup command, as follows:

The Main Menu Bar

The main menu bar appears on the second screen line of FoxPro's desktop. In many ways, this menu bar is like the tip of an iceberg. Each option in the menu, called a menu pad, displays a menu pop-up when you click it. A menu pop-up usually contains two or more menu options. Although a pop-up can have a single option, a better practice associates single actions with the menu pad directly.

You can select menu pads and their options in several ways. The most obvious method employs the mouse to click them. Pressing F10 activates the menu and highlights the first pad, File.

You might have noticed that each menu pad has one underlined letter. You can open that menu's pop-up directly by pressing the Alt key along with the underlined letter. To open the File menu, for example, press Alt+F. With any menu pop-up open, use the left- or right-arrow key to move to other pads. The up- and down-arrow keys open the current pad's pop-up list and move through its options.

In any given pop-up, some menu options might appear dimmed, which means that you cannot execute that option now. Usually, common sense tells you why the option is inappropriate. If you open the File pop-up before opening a table, database, program, or other file, for example, you cannot choose Save because you have nothing to save yet. Therefore, FoxPro automatically dims the Save option text.

While a pop-up is open, pressing the up- or down-arrow key moves the highlight from one option to the next. Pressing the left- or right-arrow key moves to the next menu pad and opens its menu pop-up-unless the highlighted option contains a right arrow along its right border, in which case pressing the right-arrow key opens a submenu that lists additional options. To choose a menu item, highlight it and press Enter. A mouse click works just as well. You can even press the underlined letter in the option, if it has one. Notice that in the pop-up menus, you do not press the Alt key with the underlined letter.

Some menu options have special key combinations, called shortcut keys, that enable you to jump to that option directly without going through the menu pads. FoxPro displays these shortcut keys along the right side of the pop-up menus. The shortcut key for File, New, for example, is Ctrl+N. This means that you can press Ctrl+N any time while you are in Visual FoxPro with the System menu active to open a new file. Table 1.2 summarizes the available shortcut keys.

Table 1.2  Menu Option Shortcut Keys
Menu Option
Shortcut Key
Select All
Find Again
Run current Program
Command Window

I'm in the middle of a Visual FoxPro application and when I enter one of the shortcut keys, nothing happens. Shortcut keys are defined through Visual FoxPro's system (or main) menu. You can override or even replace this menu with your own menu, however, when you create custom applications. If VFP's System menu or any individual menu pad is not active, these shortcut keys are not active, either.

A visual clue that has become a Windows-application standard is the use of an ellipsis (…) at the end of a menu option to indicate that selecting the option opens a dialog box with additional options. Choosing File, Open, for example, does not tell FoxPro what to open. Therefore, when you select this option, Visual FoxPro displays its standard Open dialog box. Menu options without ellipses (such as File, Close) execute immediately when they are selected.

A similar standard uses the right arrow to indicate that the option opens another menu level, as in Tools, Wizards.

The File Menu Options  The File menu pop-up list contains options related to accessing files (creating new files, opening existing ones, closing, saving, and printing). Table 1.3 describes these options.

Table 1.3  File Menu Options
Menu Option
NewOpens the New dialog box. The options in this dialog box enable you to create new projects, databases, tables, queries, connections, views, remote views, forms, reports, labels, programs, classes, text files, and menus.
OpenOpens the Open dialog box, which opens any file type listed under New.
CloseCloses the active window. If you press Shift and open the File menu, this option becomes Close All, which closes all open windows.
SaveSaves the file in the active window with its current name. For a new file that has no name, the option prompts the user for a filename.
Save AsPrompts the user for a new filename before saving the file.
Save As ClassSaves the current form or selected controls as a class definition (active only from within the Form Designer).
RevertCancels changes made in the current file during the current editing session.
ImportImports a Visual FoxPro file or a file formatted by another application. You can also use this option to start the Import Wizard.
ExportExports a Visual FoxPro file in another application's file format.
Page SetupChanges the page layout and printer settings for reports.
Page PreviewDisplays pages in a window as they will appear when printed.
PrintPrints the contents of the current window, a file, or Visual FoxPro's Clipboard.
SendEnables you to send email.
<project files if any>Provides quick access to reopen any of the last four opened projects.
ExitExits Visual FoxPro. Choosing this option is the same as typing QUIT in the Command window.

The Edit Menu Options  The options in the Edit menu provide functions that are used for editing programs, forms, and reports. This menu also contains options that create object linking and embedding (OLE) objects. Table 1.4 lists the options that appear at various times in the Edit menu pad.

Table 1.4  Edit Menu Options
Menu Option
UndoReverses an unlimited number of changes made in the current edit session. Changes made before the last save, even if made during the same session, are not reversible.
RedoPerforms a reversed change again.
CutRemoves the selected text or object from current document and places it on the Clipboard.
CopyMakes a copy of the selected text or object and places it on the Clipboard.
PasteCopies the current contents of the Clipboard to the current insertion point.
Paste SpecialUsed to insert OLE objects from other applications into a general field. You can embed objects or merely link them. Visual FoxPro stores a copy of embedded objects in the current object. When an object is linked, FoxPro stores a path and name reference to the original object only.
ClearRemoves selected text without copying it to the Clipboard.
Select AllSelects all objects in the current window. This option is used often in form and report design to move or format all objects at the same time.
FindDisplays the Find dialog box, which is used to locate text strings in files. Find options include the capability to ignore case, wrap around lines, match entire words, and search forward or backward.
Find AgainRepeats the last Find starting at the current insertion point position rather than the beginning of the document.
ReplaceDisplays the Replace dialog box, which is used to locate and replace text strings in files.
Go to LineUsed primarily during debugging to go to a specific line number in a program file. This option cannot be used when word wrap is on. (Of course, you don't have word wrap on when you edit your FoxPro programs-right?)
Insert ObjectSimilar to Paste Special, except that it does not assume that the object already exists and is stored on the Clipboard. The option embeds objects in general type fields. When chosen, Insert Object opens the other application without exiting Visual FoxPro. After creating the object in the other application, Insert Object returns to Visual FoxPro and inserts the linked or embedded object.
ObjectProvides options for editing a selected OLE object.
LinksOpens linked files (OLE) and enables you to edit the link.
PropertiesDisplays the Edit Properties dialog box, which enables you to affect the behavior, appearance, and save options of the edit windows.

Several options from Table 1.4-Paste Special, Insert Object, Object, and Links-apply only to general fields and OLE. The rest of the options apply to editing programs and fields.

The Edit Properties dialog box, opened by choosing the last option in the Edit menu, gives you control over the editor's many properties. The behavior properties, for example, turn on and off drag-and-drop editing, word wrap, and automatic indent. (Unless you are using Visual FoxPro editor as a word processor, I do not recommend using word wrap.)

You can also specify the following:

Finally, you can have VFP make a backup copy of the file when you edit it, compile the file when it is saved, save line feeds, and create an end-of-file marker. Figure 1.6 shows these features.

Figure 1.6 : Use the Edit Properties dialog box to customize the editor properties of Visual FoxPro 6.

The View Menu Options  The View menu displays options that are appropriate for viewing the current table, if one is open. If you are not currently viewing a file, the menu displays a single option (Toolbar) that opens the Toolbar dialog box, which lists the available toolbars used by Visual FoxPro 6. On the other hand, if you already are browsing a table or editing a form, menu, or report, additional options appear as described in Table 1.5.

Table 1.5  View Menu Options
Menu Option
EditChanges to an Edit layout style for viewing and changing records. The option displays fields vertically, and a horizontal line separates records (if grid lines are active).
BrowseChanges to a Browse layout style for viewing and changing records. The option displays fields horizontally; rows represent records and columns represent fields.
Append ModeAppends a blank record to the end of the table and moves the record pointer to the first field in it.
DesignDisplays the Form, Label, or Report Designer.
Tab OrderEnables you to set the tab order in forms.
PreviewShows a preview of labels or reports onscreen.
Data EnvironmentDefines tables and relations used in a form, form set, or report.
PropertiesDisplays the Properties dialog box for forms and controls.
CodeOpens the code windows when you are editing object methods.
Form Controls ToolbarOpens the Form Controls toolbar while you are in the Form Designer.
Report Controls ToolbarDisplays the Report Controls toolbar, which enables you to add controls to a report.
Layout ToolbarOpens the Layout toolbar, which helps you align controls.
Color Palette ToolbarOpens the Color Palette toolbar, which enables you to select foreground and background colors for a control.
Report Preview ToolbarProvides buttons that move between pages of the preview, change the zoom factor, print the report, and exit preview mode.
Database DesignerOpens the Database Designer, which maintains tables, views, and relationships stored in a database.
Table DesignerOpens the Table Designer, which enables you to make structure modifications to associated and free tables and to their indexes.
Grid LinesToggles the display of grid lines on and off.
Show PositionDisplays the position, height, and width of the selected object or form in the status bar.
General OptionsAdds code in a menu when you are using the Menu Designer.
Menu OptionsAdds code to specific menu options.
ToolbarsDisplays a dialog box that lists every toolbar used by FoxPro, enabling you to customize the buttons in toolbars and to create your own.

The Format Menu Options  The Format menu normally consists of options that control font characteristics, text indentation, and spacing. Additional options become available, however, when you are using the various Designers, and are described in Table 1.6.

Table 1.6  Format Menu Options
Menu Option
FontSelects a font and its characteristics.
Enlarge FontEnlarges the font used in the current window.
Reduce FontReduces the font size used in the current window.
Single SpaceSingle-spaces the text in the current window.
1 1/2 SpaceUses 1 1/2-line spacing for the text in the current window.
Double SpaceDouble-spaces the text in the current window.
IndentIndents the current or selected lines in the current window.
UnindentRemoves the indent of the current or selected lines in the current window.
CommentComments out the selected lines.
UncommentRemoves comments from the selected lines.
AlignOpens options that align selected objects.
SizeOpens options that size selected objects.
Horizontal SpacingProvides options that adjust horizontal spacing between selected objects.
Vertical SpacingProvides options that adjust vertical spacing between selected objects.
Bring to FrontMoves the selected object to the top of the objects in a form.
Send to BackMoves the selected object to the back of the objects in a form.
GroupAssociates a selection of objects in reports and enables you to work with them as a group.
UngroupBreaks a group definition into individual objects again.
Snap to GridWhen you are moving objects, repositions the top-left corner to the nearest grid intersection when the mouse button is released.
Set Grid ScaleDetermines how far apart the vertical and horizontal grids are.
Text AlignmentAligns text in the selected object.
FillDefines a fill pattern for shapes.
PenDefines a pen thickness and style for shapes.
ModeDefines whether the background of an object is opaque or transparent.

Choosing the Font option opens a dialog box that displays a list of available fonts, their styles, and sizes. The option also displays a small sample of the font in a preview window. The font list contains all fonts that are defined in Windows. Fonts that have TT before their names are TrueType fonts, which can print over a large range of font sizes and still look good. If you are editing a program file, fonts preceded by a blank are either screen or printer fonts. These fonts look good onscreen, but they have to be sent to the printer as bitmap images (which print slowly) or they use a similar font for printing. I recommend the use of TrueType fonts. You can also control some additional effects in reports, such as Strikeout, Underline, and Color.

If you develop applications for other people, be careful which fonts you use. Unless you have shareware fonts that permit distribution, keep in mind that many fonts cannot be distributed freely. If your application uses a font that other computers do not have, formatted screens and reports may not come out as planned. Common fonts that currently ship with Windows 95 include Arial, Courier New, Marlett, Symbol, Times New Roman, and Wingdings. Check your current Windows manual to verify this list.

When you use the Enlarge Font or Reduce Font option, Visual FoxPro attempts to use font sizes stored in the font file, but it can calculate other font sizes based on multiples of existing font sizes or combinations of them. Visual FoxPro can create a 14-point font from information in the 6- and 8-point fonts, for example.

Unlike the Single Space, 1 1/2 Space, and Double Space options, Indent modifies only the current or selected lines in the current window. The option indents the line by the equivalent of one tab position each time you choose it. You can set the number of characters represented by a tab position through the Properties dialog box (Edit menu).

The Unindent option removes the equivalent of one tab from the current or selected lines each time you choose it. The Comment option precedes the selected lines with the characters *!*. Only if the selected lines begin with these characters will Uncomment remove the comment characters.

The Tools Menu Options  The Tools menu provides a variety of programmer tools, ranging from wizards to the debugger. Table 1.7 defines the options in the Tools menu.

Table 1.7  Tools Menu Options
Menu Option
WizardsLists and provides access to Visual FoxPro's wizards.
SpellingPrimarily spell-checks text fields and memos.
MacrosDefines and maintains keyboard macros.
Class BrowserExamines the contents of any class to view its properties and methods or even the actual code used to create the object.
BeautifyReformats program files to add indenting and capitalization.
DebuggerOpens the Debugger window. This improved replacement for the Debug and Trace window adds windows for watch variables, locals, call stack, and the capability to track events and analyze coverage during testing.
OptionsProvides access to Visual FoxPro configuration options.

FoxPro 2.6 introduced wizards, which are programs that guide the user through specific tasks such as creating a table. A wizard uses a series of windows that ask questions about the object that is being created.

Visual FoxPro also includes a spelling checker, which you can use to check the spelling of any object's text beginning at the current location of the insertion point. Although you can use this feature to spell-check program listings, that is not the intent. Instead, use the spelling checker to spell-check long text and memo fields.

The Macro dialog box enables you to create, edit, and view macro definitions. A macro definition consists of a series of Visual FoxPro commands that you can store and execute with a single keystroke. Previously FoxPro provided eight default macro definitions, which are assigned to function keys F2 through F9. Pressing F5, for example, executes the command DISPLAY STRUCTURE, which lists the structure of the current table. Table 1.8 shows the definitions of these default macros.

Table 1.8  Default Macro Definitions for Function Keys
Opens the View window.
Lists records from the current table; opens the GETFILE window if no table is being used.
Lists all tables in the current directory.
Shows the field definitions of the current table; opens the STRUCTURE GETFILE window if no database is being used.
Shows the table open in each area. If an index is also open, F6 displays its expression. The key also shows the settings of SET commands and other system information.
Displays the values stored in all memory variables, including system variables. F7 also shows the definitions of all menus, pads, pop-up lists, and windows.
Displays the current record; opens the GETFILE window if no table is being used.
Enters append mode for the current table. Opens the GETFILE window if no database is being used.

In addition to these eight macros, you can define your own. In fact, because you can use a variety of key combinations to name macros, you can define more than 250 macros at one time.

The last option in the Tools menu is Options, which displays a multiple-page form that provides controls to customize the way you work with Visual FoxPro. VFP divides these controls into 12 distinct groups: Controls, Data, Debug, Field Mapping, File Locations, Forms, General, Projects, Regional, Remote Data, Syntax Coloring, and View. These groups are covered in more detail in the section "Setting Configuration Options" later in this chapter.

The Program Menu Options  The Program menu consists of six options that are related to compiling and running a program. Table 1.9 describes the Program options.

Table 1.9  Program Menu Options
Menu Option
DoRuns a program selected from a dialog box.
CancelCancels the current program.
ResumeResumes the current program from a suspended state.
SuspendStops the current program from executing but does not remove it from memory.
CompileTranslates a source file into object code.
RunRuns the current program. (The option appears in the menu as Do, followed by the name of the PRG.)

The Do command opens a dialog box that enables you to select the program that you want to run. (You can also execute a program from the Command window; enter DO immediately followed by the name of the program that you want to run.) You do not have to compile a program before running it; you can run a PRG directly. VFP can compile the program automatically before running it.

You can have VFP compile a program each time you save it. You can use the Edit Properties dialog box to set this flag and save it for all PRG files. Subsequent new program files inherit this property, but it does not affect existing PRG files. To change those files to automatically compile on saving, you must set the property, open, and resave the files.

Choose Program, Do, and select the program from the Do dialog box, which is similar to the Open dialog box. The Do option differs from the Run option (which appears in the menu as Do, followed by the name of the PRG), which executes the program in the current window.

VFP enables the Cancel option only when you are executing a program. To access this option, you must suspend the program or be stepping through it in the Trace window.

After suspending a program, you cannot edit the source code until you cancel the program.

Visual FoxPro enables Resume only while an executing program is suspended. The option resumes a suspended program to normal execution mode.

To suspend a program, you first need to interrupt it. You can do this while you are using the Trace window to step through the program. You can interrupt a program by inserting breakpoints into the code, using the Trace window, or setting break conditions on variables or expressions.

The Compile option opens a window similar to the Open dialog box, enabling you to select a source file. The option takes the selected program source file (PRG) and compiles it. Click the More>> button to display several additional options related to encryption and debugging, as well as to create an error file (ERR), if desired.

The Window Menu Options  The Window menu contains options that manage open windows onscreen. The menu provides options that enable you to Arrange All, Hide, Clear, and Cycle through windows. In addition, the menu enables you to bring to the front any window that is currently open. Table 1.10 lists the Window options.

Table 1.10  Window Menu Options
Menu Option
Arrange AllArranges open windows as non-overlapping tiles.
HideHides the active window but does not remove it from memory.
Show AllDisplays all defined windows.
ClearClears text from the application workspace or current output window.
CycleMoves from one open window to the next, making the next window the active one.
Menu OptionDescription
Command WindowMakes the Command window active and brings it to the top, opening it if necessary.
Data SessionMakes the Data Session window active and brings it to the top, opening it if necessary. This window serves as a valuable tool for monitoring which tables are open in each of the 32,767 work areas.
<Window List>Displays the first nine defined windows. If more than nine windows have been defined, a final option-More Windows-appears. To change focus to any window, simply click its name.

The Arrange All option resizes open windows to create non-overlapping tiles. Arrange All will not resize a maximized window. With two open windows, it splits the screen in half vertically and puts the active window on the left side. With three open windows, it also splits the screen in half vertically, putting the active window on the left side. The option then splits the right half horizontally, however, to display the other two open windows. If you have four open windows, each window receives one-quarter of the screen; the active window is placed in the upper-left corner. For more windows, you'll have to experiment.

The Hide option removes the active window from the screen. You cannot redisplay a system window (such as an edit window for a program) without reissuing the command that created it. If you hide a user-defined window, however, that window remains in memory; you can redisplay it with the SHOW WINDOW command. If you hide the current output window, it continues to receive output even while it is hidden, which means that you cannot see it. Upon redisplaying the window, you again see anything that has been written to it.

Take advantage of the capability to write to a window while it is hidden to draw complex screens. Rather than amuse the user with a light show as your program paints a screen, hide the window, add the objects to it, and show the window fully developed.

The Clear option erases text from the current screen or active window. Notice that when you use the SHOW WINDOW command after hiding a window, that window does not automatically become the active window; its status depends on whether it was the active window when it was hidden and whether you activated another window in the meantime. (To ensure that a window is active, use the ACTIVATE WINDOW command.) Therefore, be careful about what you clear.

The CLEAR command and the Clear option in the Window menu are not the same as CLEAR WINDOW, which removes the window from both the screen and memory. The CLEAR command and the Clear option only remove the text from the window.

The Data Session option opens the Data Session dialog box, which displays a list of all tables that are open in the current session. The option also displays any relations defined among these tables, as shown in Figure 1.7.

Figure 1.7 : The Data Session dialog box shows three work areas with defined tables and the relation set between two of them.

In the middle of the Data Session dialog box is a set of six buttons. The Properties button opens a window that displays the current table properties, indicating the data-buffering options that are in effect and any data filter or index order. The window also enables you to determine whether to allow access to all fields in the work area or only to fields selected with a field filter. Figure 1.8 shows the Work Area Properties window.

Figure 1.8 : The Work Area Properties window is opened by choosing Properties in the Data Session window.

If you can open the table exclusively, you can change the structure by clicking the Modify button. This button opens the Table Designer shown in Figure 1.9.

Figure 1.9 : The Table Designer enables you to define not only the fields in a table, but also indexes, field properties, and table properties.

This option enables you to change not only the fields for the selected table, but also the properties of those fields (captions, validations, defaults, and so on). You can also add, delete, or modify index expressions from the Indexes page of the Table Designer. The indexes defined here are part of the structural compound index for the current table. Finally, you can select the Table page to set record validations and triggers.

Visual FoxPro does not create indexes with .NDX extensions. The program can read .NDX indexes from earlier database systems, but it immediately converts them to its own internal index format, even though it may retain the .NDX extension. If you need to create a standalone index (.IDX) or a nonstructural compound index, you must do so from the Command window or from within a program by using the INDEX command.

To open a table in a new work area, click the Open button in the Data Session dialog box. The Open dialog box appears to help you select a table. With a table assigned to a work area, you can browse through its records by clicking the Browse button.

The Close button closes the table in the currently selected work area (the highlighted one).

The Relations button enables you to define relations between files. If you already defined persistent relations through the Database Designer, however (or if you plan to), do not repeat those relations here.

The Help Menu Options  Help is the final menu pad of the System menu. Table 1.11 lists the options available in this menu. The first two options present different ways to access the help file to get information on commands, functions, or features. The third option lists support options that are available from Microsoft. The last option opens the typical copyright screen for the product; it adds additional functionality by providing system information and allowing the user to run other applications from within FoxPro.

Table 1.11  Format Menu Options
Menu Option
ContentsDisplays help information via an outline format.
DocumentationOpens the FoxPro online documentation.
Sample ApplicationsDescribes the sample applications provided with Visual FoxPro.
Microsoft on the WebOpens a second menu with options to use your Web browser to go to a variety of Visual FoxPro pages on the Web, the Microsoft home page, and several other locations.
Technical SupportProvides a list of available resources from Microsoft that offer additional help. The list includes a section that answers common questions.
About Microsoft VisualDisplays the copyright screen for the product, along with FoxPro whom it is licensed to, version date, resource filename, default directory, and product ID. Additional features include the capability to list system information and to run other programs.

The About Microsoft Visual FoxPro option displays an initial screen that contains the standard copyright and license information. The screen includes a special bonus: the System Info button. Click this button to display information about your system, as shown in Figure 1.10.

Figure 1.10: System Information is one of several categories of information for documenting your computer system that you can access from the About screen.

If you have problems with FoxPro and call Microsoft for assistance, print this screen first. In addition, you can display more than a dozen additional categories of available information by clicking the category name in the left window.

A bonus feature of the Microsoft System Info screen is the Run option in the File menu. Click this option to display a default list of applications that you can run. This list does not include every program on your system, but by clicking the Browse button, you can open a window from which you can select any application that is available to your system. Your capability to run other programs, of course, might depend on the amount of available memory on your machine. Figure 1.11 shows the Run Application window.

Figure 1.11: The About screen has an option that permits you to run external programs from within Visual FoxPro.

The Visual FoxPro System menu is dynamic; it changes as you perform different functions and use different VFP tools. Sometimes, the changes add or remove menu pads directly; at other times, the changes occur in the drop-down menus themselves.

The Toolbar

FoxPro has several toolbars, each of which is customized for the current task. This arrangement eliminates the confusion (and space problems) of having all buttons available at all times. This section briefly examines the main system toolbar, also called the Standard toolbar. You can experiment with the toolbars in FoxPro 6 by selecting View, which opens the Toolbar dialog box. From this dialog you can select specific toolbars or customize your own selection. You should only keep open the toolbars that you will need because the screen and workspace can become quite cluttered with a lot of toolbars on the screen.

The main system toolbar contains 20 buttons and one drop-down list. As you slowly pass your mouse over any button, a small box appears below it displaying the button's name. This box is called a ToolTip. ToolTips remind you of the buttons' actions, just in case you forget. Figure 1.12 shows the buttons on the Standard toolbar along with their names.

Figure 1.12: This figure shows the definitions of the buttons in the Standard toolbar.

Table 1.12 briefly describes the purpose of each button.

Table 1.12  Buttons on the Standard Toolbar
Button Name
NewOpens the New File dialog box to create a new file.
OpenOpens the Open File dialog box to open an existing file.
SaveSaves changes made to the current file. By default, the button uses the file's original filename, except for a new file that has no name, in which case it prompts for a filename.
PrintPrints the active file, Command window contents, or Clipboard contents.
Print PreviewUses a preview window to show what Print would output.
SpellingActivates the spell checker.
CutCuts the current selected text or object and places it on the Clipboard.
CopyCopies the current selected text or object and places it on the Clipboard.
PasteCopies the current contents of the Clipboard and pastes it at the current insertion point location.
UndoUndoes the last action or command, with some limitations. The Undo button cannot undo a PACK command, for example.
RedoRepeats the last command or action.
RunAppears enabled if Visual FoxPro has an executable file open, such as a screen or program.
Modify FormSwitches the currently executing form back into designer mode.
DatabaseLists the names of all open databases in a drop-down list. The current database appears in the text box. You can switch to a different database by selecting it from the list.
Command WindowOpens or pops the Command window back into view and makes it the active window.
View WindowOpens or pops the View window back into view and makes it the active window.
Form WizardLaunches the Form Wizard.
Report WizardLaunches the Report Wizard.
AutoForm WizardCreates a form from the current table.
AutoReport WizardCreates a report from the current table.
HelpDisplays Visual FoxPro's Help Contents screen.

The Status Bar

The status bar appears at the bottom of Visual FoxPro's main screen if SET STATUS is ON. The status bar itself has two main areas: the message area on the left and indicator boxes on the right.

The message area is blank when no table is open in the current work area. When a table is open, the message area displays the following:

The Designers use this area to display the position and size of objects.

Finally, the message area displays the current sharable status of the file or current record using one of the following designations:

Visual FoxPro also uses this portion of the status bar to display system messages that concern issues such as its progress during reindexing. Forms also use this area to display text messages associated with fields and controls, as well as position and size information while you are in the Designers.

The right end of the status bar contains either three or four indicator boxes. The first box on the left indicates the status of the Insert key. This box is blank when VFP's editor is in Insert mode; otherwise, the letters OVR appear, indicating overwrite mode. The next box displays NUM when the Num Lock key is on. The third box indicates the status of the Caps Lock key, displaying CAPS when the key is on. Finally, a fourth box may appear displaying the current time.

The View page of the Options dialog box (choose Tools, Options to display this dialog box) controls whether to display time in the status bar. Alternatively, you can enter SET CLOCK STATUS to turn on the clock in the status bar.

Controlling Windows

All windows, whether they are system windows or user-defined ones, have common features, although for any single window, one or more of the features may not be active. The following sections examine the Command window to help you become familiar with these features.

Zooming Windows

As mentioned earlier in this chapter, the title bar of a window has several buttons on the right side. The button with the lower horizontal line minimizes the window, representing it with an icon or docking it in the taskbar. (For windows within FoxPro, however, this button docks the icon on FoxPro's main screen, not the Windows desktop.) The button with the single window image maximizes the window. For a maximized window, the Restore button replaces the Maximize button; it has the image of two cascaded windows.

If you do not have a mouse, or if you just prefer not to take your hands off of the keyboard long enough to pick up the mouse, you can zoom the window by using shortcut keys. You can open the Windows 95 Window menu by pressing Alt+-. This shortcut key displays the options and their shortcut keys. Table 1.13 lists the shortcut keys, which work consistently across all Windows applications.

Table 1.13  Commands in the Window Menu with Their Shortcut Keys
Shortcut Key
Returns the window to its original size.
Enables you to move the window with the arrow keys.
Enables you to size the window with the arrow keys.
Minimizes the window and displays it as an icon.
Maximizes the window.
Closes the window.
Next Window
Activates the next window.

The Next Window command in the Control menu duplicates the functionality of the Cycle option in the Window menu. Thus, you can use either Ctrl+F6 or Ctrl+F1 to cycle through open windows.

Resizing Windows

Maximizing and minimizing a window are not your only resizing choices; you can also "grab" any portion of the border to stretch the window. In fact, as you move the cursor around the border, you can see that Visual FoxPro divides the border into eight segments, one for each side and corner. Placing the mouse on any edge changes the cursor to show the direction in which the border stretches. Side segments stretch the window horizontally or vertically. Corners stretch the window in two directions at the same time.

If you don't have a mouse (but you really should get one before going much further with any Windows product; mice are relatively cheap and don't eat much), you can follow these steps to resize a window:

  1. Press Ctrl+F1 to cycle through the open windows and activate the window you want to resize.
  2. Open the control box by pressing Alt+- (Alt plus the hyphen/minus-sign key).
  3. Choose Size by pressing S or by selecting the option and pressing Enter.
  4. Now use the arrow keys to stretch the window. Notice that as you press the first arrow key, the cursor moves to the border in that same direction. If you continue to press the same arrow key, or the one for the opposite direction, the window expands or shrinks, respectively. If you press either of the two other arrow keys, the cursor moves to the corresponding corner first. Now you can use any arrow key to stretch or shrink the window from the current corner while the opposite corner remains fixed.
  5. When you have the window sized the way that you want it, press Enter.

Later, when you create your own windows, you learn how to control which, if any, of these features remain active. Indeed, for some applications, you do not want the user to change the window's size.

Moving Windows

The easiest way to move a window is with the mouse. Simply click the title bar and drag the entire window anywhere on the screen. If you try to drag the window off the screen, VFP stops the movement when the mouse reaches a screen edge. Therefore, you cannot drag the window completely off the screen by using the mouse.

You also can move the window by using the keyboard. Follow these steps:

  1. Press Ctrl+F1 to cycle through the open windows and activate the window you want to move.
  2. Open the control box by pressing Alt+- (Alt plus the hyphen/minus sign).
  3. Choose Move by pressing M or by selecting the option and then pressing Enter.
  4. Now use the arrow keys to move the window.
  5. When you have the window where you want it, press Enter.

Understanding Common Window Objects

Many common components appear in Visual FoxPro's dialog boxes, as well as in custom-designed forms. Figure 1.13 shows the most common components used in the Visual FoxPro interface.

Figure 1.13: Examples of common screen elements used in Visual FoxPro.

Labels  A label is a fixed text string displayed in a form. VFP uses labels for titles and to identify other objects in forms.

Text Boxes  Text boxes contain character variables. These boxes can obtain their values from tables or they can represent memory variables. In either case, when text boxes appear in a form, you can edit them by selecting the text and making any changes.

Although a text box has a physical length onscreen, this physical length does not limit the length of the data that it contains. You control data length by using PICTURE clauses or by automatically truncating data to the length of table fields. You can also set the maximum length property of the text-box control. For longer values, text boxes can be more than one line high.

Edit Boxes  Edit boxes also enable you to edit character strings. The main advantage of an edit box is the scrollbar, which enables you to edit long strings and even memos.

List Boxes  The purpose of a list box is to display a series of options. Table 1.14 displays possible list sources.

Table 1.14  List-Source Values for List Boxes
Source ID
SQL statement
Query (.QPR)

Option Groups  Option groups (previously called radio buttons) limit the user to selecting one option from the group. Within a group of option buttons, you can select only one button at a time. In fact, the order of the option buttons in the group defines the value of a single variable. If you click a second button, the preceding selection is released. The setup is just like the preset buttons on a car radio.

Remember that a variable can have only one value.

A selected button displays a black dot inside the circle. A deselected button is just an empty circle.

A box automatically surrounds the option group on creation. This box is especially important visually if you have more than one option group in a form, because each group can have one-and only one-selected button.

Check Boxes  Visual FoxPro uses check boxes to represent binary states. Binary states are either on or off like a switch, thus the name: binary switch. Because many configuration options used by VFP are either on or off, forms that display them usually use check boxes. A selected check box, which represents the true state, contains a bold check mark. Otherwise, the box is blank. Although a form can have more than one check box, each one represents a unique variable or field. Therefore, you can select as many check boxes as you want.

Check boxes now support a third value, null, which means neither true nor false; its value is unknown. To use this capability, you must represent the check box value as a number ranging from 0 to 2. In this case, 0 represents false, 1 represents true, and 2 represents unknown. When a check box is set to null, its background is dimmed.

Spinners  Spinners provide an interesting way to select integer values. These elements use a text area to display the current value. To the right of this text area are two buttons, one on top of the other. The top button has an up arrow; the bottom one has a down arrow. Clicking the top button increments the spinner value; clicking the bottom button decrements the value. You also can change the value directly by selecting in the text area and entering a new value.

In most cases, spinners have minimum and maximum values. A good use for a spinner is to obtain the number of copies when you route a report to a printer. In this case, a minimum value might be 0 (no report) to 10 (10 copies).

Spinners can directly use only numeric variables, but you might reference the variable in this control to display and control other data types, such as dates or strings.

Combo Boxes  A combo box combines the best features of a text box with those of a list. Visual FoxPro uses two variations on combo boxes. The one shown in Figure 1.13 is a drop-down combo box, which enables the user to enter a new item in the box next to the button. The user can also click the arrow to the right of the box to display a list of predefined choices. The second type of combo box is called a drop-down list. The primary visual difference is that the arrow is connected to the text area in a drop-down list. Functionally, however, drop-down lists enable you only to select values that are in the list.

Command Buttons  Command buttons (or push buttons) appear as three-dimensional shaded rectangles. A command button usually displays a text caption or bitmap image that identifies its purpose. To execute the action associated with a button, simply click it.

Most Visual FoxPro dialog boxes have one command button that has a slightly darker border than the other buttons. This button executes as the default if you press Enter.

Some command buttons have ellipses (…) after their captions to indicate that they open another dialog box. Another common button convention uses the label MORE>>. When you click such a button, the current window expands to reveal additional options.

Page Frames  Finally, all of these controls (except for the initial label field) appear in a page frame. Each page in the page frame has a tab along the top. Sometimes multiple rows of tabs are necessary. Clicking a tab displays a new page of options within the same window.

Effectively, page frames provide a mechanism to display more controls in a single window by dividing them into multiple pages. Another way to think of page frames is to think of them as layers.

Visual FoxPro supports other elements for creating forms. In addition, a large number of OCX controls are provided with Visual FoxPro. Also, many of the OCX controls provided by third-party tool suppliers work with Visual FoxPro, as well as with Access and Visual Basic. The controls described in this chapter are the basic controls included with Visual FoxPro; they provide the basis for interacting with VFP dialog boxes, builders, and designers.

Introducing the Project Manager

The Project Manager has two primary purposes:

Consider the fully developed project file that comes with FoxPro: the Tastrade project. To open a project, enter the following command in the Command window:


(Alternatively, you can choose File, Open.)

In the dialog box that appears, change the contents of List Files of Type to Project, if necessary. Next, use the Drives and Directories options to switch to the drive and directory in which the Tastrade example is stored. You should see the project name TASTRADE.PJX in the selection box. To select it, simply double-click.

You can also enter the full pathname of the project file in the box immediately below the label Filename.

The Visual FoxPro Project Manager should open, as shown in Figure 1.14.

Figure 1.14: Project Manager initially displays all file types for Tastrade.

You should be aware of several features of the Project Manager. First, if you previously used FoxPro 2.x, the Project Manager no longer lists all files of all types in a single list; rather, it divides the files by type. Page tabs that identify the first group level appear across the top of the window. Each page further divides each major file group into specific file types. Using an outline structure, the following list shows the organization of files in a project:

Class Libraries

Actually, you can get a single list by choosing Project, Project Info and then selecting the Files page of the resulting dialog box to see an alphabetical list of all files in the project. The list indicates the last modified date and code page for each file, as well as whether it is included in the project.

In fact, you can see each of these groups by clicking each of the tabs successively. In Visual FoxPro, this form structure is called a page frame. By using tabs across the top of the page frame, you can select different groups of data. This structure makes more information fit on a single screen by creating page overlays; it also helps users organize information. In this case, you can more easily find the names of programs when they are grouped by type than you can when all types appear in a single mixed-type list, as in earlier versions of FoxPro.

If you click the Data page (and if no one else has been working with the project), you should see three subgroup titles below Data: Databases, Free Tables, and Queries. Notice the plus sign before Databases. In this outline-like structure, a plus sign indicates that additional details are hidden in this item. To view these details, click the plus sign (an action that is also called drilling down).

In this case, only one item drops out of Databases: Tastrade. This fact means that the project has only a single database named Tastrade.

Tastrade has a plus sign before it. Clicking the plus sign displays another set of categories:

Local Views
Remote Views
Stored Procedures

Later chapters define tables, queries, views, and remote data access, and further explain what these groups mean. For now, concentrate on the Tables line, which is preceded by a plus sign. Click this plus sign to list the tables stored in database Tastrade.

At this point, I should clarify the terms database and table. In the past, FoxPro developers used these terms interchangeably, but the terms were never meant to be interchangeable. The misuse of the term database started in the early days of Ashton-Tate's dominance in the database market. Because of the company's dominance for many years, the term database, as used to refer to a single table, persisted.

In 1995, Visual FoxPro corrected the misuse of these terms by creating a separate object called a database container, which holds and/or organizes one or more tables. Most FoxPro programmers can associate a table with a single file that has a .DBF extension and that contains records and rows of data. The introduction of the database container, however, goes beyond the mere collection of tables. The database container also provides a platform to expand the traditional definition of a table by providing the following:

Finally, the project displays another level beyond the list that contains the table's fields. Figure 1.15 shows the first portion of a fully opened outline for Databases.

Figure 1.15: You can open successive levels of details about databases until you reach the list of table fields and indexes.

You may want to take a few moments to explore the contents of various levels of the Project Manager. Not every group contains the files in this example, but you get the idea of the way that the Project Manager organizes files.

Adding and Removing Files

Adding a file is a simple process. First, select the group to which you want to add a file, and then click either New or Add. Project Manager knows what type of file you want to add by the group that you selected. If you choose New, VFP first prompts you for a filename; it then opens an appropriate builder or designer to create that file. If you select the Tables group in the Data category, for example, the Project Manager first prompts you to determine whether you want to use a wizard or a designer. If you choose the designer, you must assign a name to the created table. Then the Project Manager opens the Table Designer or wizard so that you can define the table's structure.

If the file already exists, click the Add button. Project Manager responds by prompting for the filename, using the Open dialog box, and then adding the file to the appropriate project group.

To remove a file, such as a table, highlight it and then click the Remove button. If the file is a database table, VFP displays a window asking Do you want to remove the table from the database or delete it from the disk? For other files, VFP asks a similar question: Do you want to remove the file from the project or delete it from the disk? In either case, deleting a file from the disk also removes it from the project.

You can also see these options, like Remove, by right-clicking on the desired object.

Viewing Files

When you are viewing a file, the Project Manager treats tables differently from most other file types. To view a table, highlight it and then click Browse. This action opens the table in a Browse window, where you can view the table's records (represented as rows) and fields (represented as columns). Think of this action as "running" the table. Clicking the Modify button opens the Table Designer.

If, instead, you want to view a program's code, highlight it and click Modify. This action opens an edit window that lists the program code.

Similarly, click Modify to open and view a form, report, or label design. Each time you click Modify for one of these file types, VFP opens the appropriate designer tool.

You have just learned an important concept of object-oriented programming, called polymorphism. In each case in which you used Modify, the Project Manager opened the file with a different tool. Project Manager knew which tool to use because of the selected file type.

Using Modify to view a file can be dangerous because you can inadvertently save changes to the file. If you know that you did not make any changes, but VFP asks you to save your changes when you exit a file, just click No.

Modifying Files

To return to tables for just a moment, you may ask why you would click Modify in the Project Manager. Actually, the preceding section stretched the terms a little by using Modify to view program code, forms, reports, or labels. The Modify button actually told Project Manager to modify those items, even though you only intended to view them. Therefore, as you may guess, the Modify button for tables takes you to the Table Designer, which enables you to modify the table's fields and indexes, not just view them.

Think of the Browse button as being the action button for a table. You cannot run a table, but you can look at it. On the other hand, you certainly can run a program, screen, report, or label. In this case, Run is the action button. Therefore, Project Manager renames the Run button Browse for tables.

Does this fact mean that you can store your PRG files in the Code-Programs group and then click the Run button to test them? Absolutely! It does not matter whether you intend to build an application from all the files in the project or whether you merely want to run individual programs, reports, or labels-use the Project Manager as your standard tool for file organization and testing. Also consider keeping a separate VFP project for each physical project that you work on. You can include the same file-whether it is a table, program, form, or whatever-in more than one project file.

Furthermore, you do not have to save all individual files in a project in the same directory. Therefore, you might want to organize your files by type. Consider storing order-entry files in one directory, inventory files in another, invoices in a third, and so on.

Remember that any one application can call on tables or other files from several areas. Merely add the file to each project that requires it.

You probably have been wondering about another symbol in the group listings. This symbol-a circle with a slash through it-tells the compiler not to include this file in the compiled application or executable file.

Similarly, you may have noticed that one of the programs in the Code-Programs group is displayed in bold text. This formatting identifies the main program of an application to the compiler.

Setting Configuration Options

As mentioned earlier, Visual FoxPro enables the user to set a large number of parameters that determine how it works. In fact, VFP has so many options that they would never fit on a single screen page. But with a page-frame-style form, FoxPro can overlay several pages of options in a single window.

That is exactly what the Tools, Options command does. The resulting dialog box includes 12 tabs that divide the set options into the following logical sets:

Controls Options

The Controls page enables you to select class libraries and OLE controls. A class library contains one or more custom visual classes that you define from FoxPro's base classes. An OLE control is a link to other OLE-supporting applications (insertable objects) and ActiveX controls. Class libraries and OLE controls selected in this page appear in the Form Controls toolbar of the Form Designer when you click the View Classes button. Figure 1.16 shows the options in this page frame.

Figure 1.16: The Controls page of the Options dialog box defines connections to visual class libraries and OLE (ActiveX) controls when you are creating forms.

Data Options

The Data page includes options related to the following:

Figure 1.17 shows these settings.

Figure 1.17: The Data page of the Options dialog box defines features related to data access, retrieval, and display.

The Open Exclusive option determines how VFP opens a table in a shared environment. When this option is selected, VFP attempts to open the table exclusively, which means that no one else can have the table open. If you or someone else has the table open in another session or machine, VFP will not open it again. After VFP opens the table, no one else can open it.

Some commands require exclusive access to tables. These commands include the following:

If you work in a standalone environment, use SET EXCLUSIVE ON. Performance will improve because VFP does not have to check or maintain record lock tables (internal information that identifies which records or files are locked by a user editing them).

Autosave corresponds to the SET AUTOSAVE command. When this option is set, Visual FoxPro flushes file buffers back to disk when you exit a READ command or return to the Command window.

Show Field Names corresponds to SET HEADINGS and determines whether field names appear above columns during commands such as AVERAGE, DISPLAY, LIST, and SUM.

The Prompt for Code Page option determines whether to prompt users for a code page. Code pages perform character translations for international users when they are turned on. VFP displays the Code Page dialog box when you open a table exclusively and the table does not already have an associated code page. (See SET CPDIALOG in the VFP Online Help.)

Ignore Deleted Records determines how Visual FoxPro processes records that are marked for deletion when it performs a record-level function. First, you must understand that when you mark a record for deletion with the DELETE command, VFP does not physically delete the record; it merely marks the record in the table. Only the PACK command can physically delete marked records. Therefore, you need to decide whether you want to see or process records that are marked for deletion. In most cases, you probably don't want to process deleted records (unless you have a program option to recall deleted records). Therefore, you would check this option. When Ignore Deleted Records is not checked, VFP processes a record marked for deletion just as it does any other record in the table. This option corresponds to the SET DELETED command.

Since version 2.0, FoxPro has included a search-optimization technique called Rushmore, which uses existing indexes to perform data searches more rapidly. Under most conditions, you want to take advantage of Rushmore. At times, however, Rushmore might actually impede performance. You can globally control Rushmore with the Rushmore Optimization option. Most commands that use Rushmore also contain a clause that turns it off. Thus, you should turn on Rushmore in this page and turn it off only as needed in individual commands. (See SET OPTIMIZE in the VFP Online Help.)

The Unique Records in Indexes option controls the default that FoxPro uses in creating indexes. If this option is not selected, indexes can contain duplicate key values. In other words, if you index on last name, the index file can contain pointers to two or more Smiths, for example. When the option is selected, indexes maintain pointers only to unique key values, even if multiple records with the same key value exist. In the case of the multiple Smiths, the index maintains a pointer to only the first one. If you do not select Unique Records in Indexes, you can selectively create unique indexes by using the UNIQUE clause of the INDEX command. While this option is set, you cannot create nonunique indexes programmatically. Unique Records in Indexes corresponds to SET UNIQUE.

Collating Sequence enables changes to the collating sequence during sorts to accommodate different character sets for users in other countries. The default, machine sequence, uses the ASCII equivalents of each character. This option corresponds to the SET COLLATE command. If you SET COLLATE to GENERAL, the indexes that you create will be case insensitive.

Record-Counter Interval determines how frequently VFP reports its progress during commands such as REINDEX and PACK. This value can range from 1 to 32,787 records processed. Increasing the frequency can affect performance, however, because of the need for more frequent screen updates. (See SET ODOMETER in the VFP Online Help.)

Memo Block Size defines the number of bytes that VFP assigns to a memo at a time, from 33 bytes on up. Values of 1 to 32 allocate blocks of 512 bytes (1 = 512, 2 = 1,024, and so on). The smaller the number of allocated bytes, the less space you waste in the memo file. New to VFP is the capability to set the block size to 0, which actually allocates space in single bytes, resulting in no wasted space. You pay a performance penalty, however, if you make the block size too small. When VFP creates a memo file, the block size for it remains fixed. (See SET BLOCKSIZE in the VFP Online Help.)

The Browse-Refresh Interval option determines how frequently VFP resynchronizes data displayed in a Browse screen with the actual table source. Numbers between 1 and 3,600 refer to the number of seconds between each refresh. A value of 0 causes a refresh as soon as another user updates the table with a new value and unlocks the record. This option also corresponds to SET REFRESH.

Table-Refresh Interval determines how frequently VFP resynchronizes data displayed from a table with the actual table source. Numbers between 1 and 3,600 refer to the number of seconds between each refresh. A value of 0 does not cause a refresh when another user updates the table. (See SET REFRESH in the VFP Online Help.)

The next three options control how string comparisons are made.

SET NEAR controls what FoxPro does when a search fails. If this option is not selected, FoxPro leaves the record pointer at the end of the file. When this option is set, FoxPro leaves the record pointer at the next record alphabetically from the position where it expected to find the search value. This option corresponds to the SET NEAR command.

The SET EXACT option also controls how FoxPro performs a search. When this option is set, the search field must match the search criteria exactly, character for character and in total length. When this option is not set, the search must match character for character, up to the length of the value on the right side of the search expression. This option corresponds to the SET EXACT command.

SET ANSI controls how SQL performs string comparisons. When this option is selected, Visual FoxPro pads the shorter of the two strings with blanks to make both strings equal in length. Then VFP compares each string, character for character, to see whether the strings match. When this option is not set, it compares the strings character for character, up to the length of the shorter string (on either side of the expression). This option corresponds to SET ANSI.

The last set of options affects how Visual FoxPro handles file and record locks in a multiuser environment.

FoxPro automatically sets and releases file and record locks for file-related commands when it shares tables. Normally, you want to have the Automatic File Locking option turned on unless you intend to handle all locks manually through your code. This option corresponds to SET LOCK.

Normally, FoxPro releases the current record lock if you set a lock on a new record. You may want to lock several records at the same time, however, to update them simultaneously. In these cases, you want to select the Multiple Record Locks option. You can also set this option programmatically with the SET MULTILOCKS command. Only by setting multiple record locks can you activate buffering.

Buffering determines how to maintain data in a multiuser environment. Visual FoxPro has five buffering methods. For more information on buffering, see CURSORSETPROP() in the VFP help system.

The Reprocessing options determine how frequently or how long Visual FoxPro attempts to establish a lock when the lock fails. When you are working in a shared environment, you typically want FoxPro to retry setting locks if the first attempt fails. This option controls the number of retries up to 32,000. In addition, values of -2, -1, and 0 have special meanings. For details on these options, see the command SET REPROCESS in the VFP Online Help.

Debug Options

The Debug options customize the way that the Debugger works. Figure 1.18 shows the options in the Debug page.

Figure 1.18: The Debug page of the Options dialog box controls FoxPro's default Debugger features.

The first option enables you to select the environment for the Debugger. The environment option enables you to select either the Debug frame or the FoxPro frame. The Debug frame keeps all the debugger windows in one large frame called the Visual FoxPro Debugger. The FoxPro frame enables individual debugger windows to appear in the VFP main window. You can also display timer events during debugging. Be aware, however, that this option may result in a substantial increase in the debugger output.

Next, you can specify which window in the debugger you want to define properties for. Properties that you can set include the font and colors.

Field Mapping Options

This feature, new to VFP 5.0, is one of the most useful for customizing the way that the form builders work. Previously, the type of object associated with each field type was fixed, and in most cases, that object was a text box. When you add a numeric field, you may not want to use a text box; you may want a spinner instead. Similarly, you probably want to use a check box as the default control for a logical field and an edit box as the default for a memo field. With the Field Mapping page, you can now set the default control associated with each field type, as shown in Figure 1.19.

Figure 1.19: The Field Mapping page of the Options dialog box controls which base-class object is associated with each field type when you are using the Form Designer.

You can even associate a field type with a custom class in a class library. You could associate a logical or integer field with a group of option buttons, for example, as shown in Figure 1.20.

Figure 1.20: The Field Mapping page of the Options dialog box controls which base-class or custom object is associated with each field type by selecting Modify to display the Modify Field Mapping dialog box.

This page also enables you to determine whether to implement drag-and-drop field captions. When checked, this option gets the field caption from the table-structure property, Caption, and includes it on the form when adding a field. Similarly, you can copy the field comments, input masks, and formats from comparable table-structure properties. These database options use the power of the data dictionary and help provide consistency across applications.

File Locations Options

FoxPro uses many files, and it should not come as a surprise that those files do not all reside in the same directory. VFP uses the File Locations page to define the locations for 10 classes of files. Figure 1.21 shows this page, and the following paragraphs describe some of the auxiliary files and tools that require their file locations to be specified.

Figure 1.21: The File Locations page of the Options dialog box defines the paths of various auxiliary files and tools used by Visual FoxPro.

FoxPro first attempts to locate tables and program files in the default directory if you do not supply a full pathname at the Default Directory prompt. The current directory can be any directory, not just the Visual FoxPro root directory. In fact, you can change the directory programmatically at any time with the SET DEFAULT TO command.

Use Search Path to tell VFP where to search for files that are not in the default directory. You can include multiple directories if you separate them with commas or semicolons. This option corresponds to the SET PATH command.

Although VFP attempts to keep as much data in memory as possible to improve performance, sometimes it must create temporary files in response to commands. Visual FoxPro writes these files to a common directory specified in the Temporary Files text area. In a networked environment, keep temporary files on a local drive to improve performance.

Help File identifies the name and location of the help file. Usually, this is the FoxPro help file. If you create a custom help file for your users, however, you can identify it here. You can change the current file at any time, of course, by using the SET HELP TO command.

The resource file-which stores information about the way you work, edit preferences, window size and position values, color schemes, printer information, and much more-is designated in the Resource File text area and check box. Usually, VFP stores the resource file as FOXUSER.DBF in the VFP root directory. In a networked environment, however, you can either have individual resource files or a shared resource file. To be shared, a resource file must be read only, which defeats some of its purpose. But would you want someone to change your color scheme to something like Hot Dog Stand in the middle of running a series of applications? In shared environments, you might need to write programs that work with two resource files: one private with read-write rights and one shared.

The converter application, in the Converter text area, takes objects such as screens and reports written for earlier versions of FoxPro and converts them to Visual FoxPro 6. This conversion consists primarily of a file restructuring. If you begin with a DOS version of a screen, the converter creates a Windows screen, but it cannot add features that are unique to VFP; you must, alas, do that yourself.

Most larger applications use a main menu to tie together various parts of the system. Rather than write menu code manually, you can save time by using the menu builder. The Menu Builder locates this tool using both the path and name.

To use the spell checker, you must identify its directory and name in the Spell Checker box, if it is not in the FoxPro root directory.

FoxPro includes builders for several objects, such as ComboBox and ListBox. Builders are tabbed dialog boxes used to create and modify the objects. Builders help set the properties for these objects.

Visual FoxPro comes with wizards that help develop various features of your application. All wizards must reside in the same directory and application file. The Wizards option identifies that directory.

Forms Options

Almost every application requires at least one form. Using the Form Designer requires a few special options, including grids, screen resolution, tab order, and template classes. Figure 1.22 shows the Form options.

Figure 1.22: The Forms page of the Options dialog box controls features used in the Form Designer.

With Grid Lines, you can elect to show a grid. Dotted horizontal and vertical lines appear onscreen based on the spacing parameters defined later in the form page. You don't need to display the grid to use it; you can position objects in the grid's spaces by setting Snap to grid, regardless of whether the grid is actually displayed.

When turned on, Snap to Grid automatically moves objects to the nearest grid intersection when you change their position or add new objects. The option does not affect the positions of objects that you placed previously unless you try to move them.

The Horizontal Spacing option defines the number of pixels between horizontal grid lines.

The Vertical Spacing option defines the number of pixels between vertical grid lines.

When selected, Show Position displays the position of the upper-left corner and the size of the current object in the status bar.

Tab Ordering determines how to sequence fields that receive focus as you press the Tab key when running the program. Tab Ordering has two options: Interactive and By List. When Interactive is set, the user must press Shift while clicking the mouse to select the object order. At the same time, each object displays a small box with a number showing its current tab-sequence number. Alternatively, the tab order can be displayed as a list. You can reposition fields in the list by dragging them to a different position, thus changing the tab order.

In Windows, positioning of objects cannot be based on characters and rows because characters can vary in width and height from object to object. Instead, you position all objects based on pixels or foxels, which you can choose with the Scale Units option. Pixels are individual dots of color onscreen. Most VGA monitors use a standard 640-by-480 pixel display. Visual FoxPro, however, defines a foxel as being equivalent to the average height and width of a character in the current window font.

Use foxels rather than pixels when you are transporting a screen from a character-based platform, such as DOS, to a graphical-based platform.

Use the Maximum Design Area option to match the resolution of the user's monitor and monitor driver. You can still develop using a higher resolution supported by your own display. The Maximum Design Area then limits the size of forms you can create so that they fit on the user's reduced-resolution screen.

If you develop applications for other people, beware of developing screens with a resolution largerthan those people use. Doing so will cause display problems when you attempt to install the application. Always use the lowest screen resolution of all your expected users.

You can define two template classes, which identify default templates for forms and form sets.

The button to the right of the Form Set text box opens the Registered Library drop-down list of available class libraries selected in the Controls page. Simply select the form-set class that you want to use as a default in designing your application.

The button to the right of the Form text box also opens the Registered Library drop-down list of available class libraries selected in the Controls page. Simply select the form class that you want to use as a default in designing your application.

Choose the Builder Lock option to automatically display the builders when you add controls to a form.

Finally, you can ask VFP to prompt you to save changes after you edit a form before running the form. If you don't do this, VFP automatically saves the changes before running the form.

General Options

The next page defines general options, including those that deal with compatibility, color, confirmation, and sound issues. The page also includes options that affect programming and data entry. Figure 1.23 shows this page.

Figure 1.23: The General page of the Options dialog box sets miscellaneous options that do not fit in any of the other tabs.

The Off option in the Warning Sound group determines whether to sound the bell when the user reaches the end of a field or enters invalid data. The corresponding command is SET BELL.

The Default option sets the bell frequency and duration to their default values. SET BELL TO [nFrequency, nDuration] supports frequencies from 19 through 10,000 Hz, with a default of 512. Duration ranges from 1 to 19 seconds, with a default of 2 seconds.

With Play, you also can choose a .WAV file to use instead of the impersonal beep. Click the button that has the ellipsis to display a dialog box from which you can pick a .WAV file.

If VFP cannot locate the specified waveform, it uses a default defined in the Registry. If VFP finds no waveform there, it plays no sound. For you real techheads, the location of the default sound in the Registry is
I do not recommend, however, that you make changes in the Registry without first making a backup of the Registry.

The dBASE Compatibility option controls the compatibility of Visual FoxPro with other Xbase languages. By default, this option is not selected, thereby enabling Visual FoxPro to run programs written in earlier versions of FoxPro and FoxBase. When the option is selected, Visual FoxPro interprets the commands shown in Table 1.15 differently.

Table 1.15  Commands Affected by the Set Compatible Command
Compatible On
Compatible Off
@...GET...RANGEAlways checks Checks range only if range data changes
@...SAYOutput to the FoxPro Output to the FoxPro desktop desktop scrolls as truncates after reaching the necessary lower-right corner
@...SAYRounds the right-most digit in the PICTURE clause Truncates the right-most digit in the PICTURE clause
ACTIVATE SCREENWhen activating the screen or a window, the cursor position is 0,0 When activating the screen or a window, the cursor position is unchanged
APPEND MEMOThe default extension is TXT No default extension
GO/GOTO (with SET TALK ON) Outputs a message with the current work area and record number No message
INKEY()Home and Shift+Home returns 26; Ctrl+ Left returns 1 Home and Shift+Home returns 1; Ctrl+L returns 26
LIKE()Trailing blanks in both before comparison expressions are trimmed Trailing blanks are retained and are significant
MENU and POPUPPop-up lists are placed in the active output window with the cursor positioned on an option Pop-up lists are placed in their own window while the cursor remains in the active window
Nested ReadsPerforms an implicit CLEAR GETS when returning to a higher level Pending GETS remain when returning to a higher level
Passed ParametersParameters passed by reference remain available in the called procedure Parameters passed by reference are hidden in the called procedure
PLAY MACROAdds an implicit Alt+F10 before macros that begin with A-Z; adds an implicit Alt before macros F1-F9 No implicit keystrokes are added
READPerforms the VALID clause when you press Esc Does not perform the VALID clause when you press Esc
RUNCursor moves to the first column in row 24 before beginning output; when done scrolls output up three lines, Output begins at the cursor's current position; when done, scrolls output up two lines
SELECT()Returns number of highest unused work area Returns number of currently selected work area
SET MESSAGEDisplays the character expression in the last line of the screen Displays the character expression only if SET STATUS is ON
SET PRINT TOOutput file has a default extension of .PRT No default extension for output file
STORECannot initialize all elements of an array Can initialize all elements of an array
SUMUses the number of decimal places specified by SET DECIMALS Uses the number of decimal places specified by the field being summed
SYS(2001,'COLOR') COLOR USEReturns value of current SET COLOR. If a VFP path is set and USE includes a drive, VFP searches only that drive Returns value of SET TO Color color pair. If a VFP path is set and USE includes a drive, VFP searches that drive first; then it searches the path

When selected, the Use Visual FoxPro Color Palette option tells Visual FoxPro to use its own default color palette when displaying .BMP (bitmap) images. Otherwise, VFP uses the color palette used to create the .BMP. This option corresponds to the SET PALETTE command.

The Confirm File Replacement option determines whether VFP shows a warning message before overwriting an existing file. This option corresponds to the SET SAFETY command.

The Browse IME Control is only enabled when using a double-byte character system. It displays an Input Method Editor when you navigate to a text box in the Browse window. It corresponds to the IMESTATUS function.

The General page includes three programming options, which primarily affect developers.

Selecting Cancel Program On Escape enables the user to press the Esc key to terminate a program's execution. Although this capability is essential during development, you might not want to enable users to press Esc while they are running a production version of the application. The program code provides a better, more secure place to control this option by means of the SET ESCAPE command.

Log Compilation Errors, when you compile a PRG file to create an FXP, APP, or EXE, causes VFP displays errors to the screen. You might prefer to log compilation errors to an error file rather than interrupt the compilation for each one. Then you can go back to the log file and deal with each error individually. The error file has the same root name as the PRG (when you are compiling standalone PRGs) or the project file (when you are compiling projects), but it uses the extension .ERR.

If you select the SET DEVELOPMENT option, VFP checks to see whether any changes have been made in the source file before running a compiled FXP. Similarly, if you work with projects that contain groups of files, the option checks the source of each component with the last compile date of the APP or application file. If any of the source files have more recent time and date stamps, the option recompiles the project.

Finally, this page contains three data-entry options, which affect the way that users interact with the applications.

The Navigation Keys option has two navigation options: Windows-Compatible and DOS-Compatible. This command corresponds to SET KEYCOMP. Some examples of differences between Windows and DOS navigation appear in Table 1.16.

Table 1.16  Differences Between DOS and Windows Compatible Modes
EnterCtrl+EnterSelects the default button in a dialog box
Alt+letterSingle letter Accesses keys for controls
Spacebar, Alt+Up Arrow, Alt+Down Arrow Enter or spacebarOpens a combo box that has focus
Up, Down ArrowTabMoves between a group of option buttons
SelectedNot Selected Status of browse field upon entry into cell

The Fill New Records With Current Values option tells Visual FoxPro to carry forward all fields from the current record to a new record. This feature has value if only a few fields change from one record to the next. This option corresponds to the SET CARRY command.

SET CARRY includes a TO option that specifies which field values to carry forward. Often, this option is a better choice than carrying forward all fields.

When the user enters data in a field, Visual FoxPro automatically moves to the next field when it reaches the maximum number of characters for the current field. If SET BELL is ON, VFP beeps as it moves to the next field. If SET BELL is OFF, users have no warning that they are now in another field unless they are very observant. If you choose Enter or Tab to Exit Fields, you have the option to force users to press the Enter or Tab key to move from one field to the next (SET CONFIRM). Although this option slows some data-entry people, it prevents them from accidentally writing data in the next field.

Projects Options

The Projects options pertain to features associated with using the Project Manager to maintain and compile applications. The page also includes options that affect the user of Visual Source Safe with VFP. The only two project-specific options are Project Double-click Action and Prompt for Wizards. Figure 1.24 displays this page of options.

Figure 1.24: The Projects page of the Options dialog box defines both Project Manager and Visual SourceSafe options.

The first option determines the effect of double-clicking a filename in the Project Manager. Choose the Run Selected File option if you want to run a file when you double-click it in the Project Manager. Choose the Modify Selected File option to merely select the file for editing.

When checked, the second option-Prompt for Wizards-automatically asks whether you want to use a wizard when you are starting a new file from the Program Manager.

Display User-Defined Container Icons tells VFP to display the icons of user-defined containers in the Project Manager.

This page also contains the source-control options. If you have Microsoft Visual SourceSafe (VSS) installed, it appears in the combo box next to the Active source control provider text. Otherwise, <None> appears and all source-control options are inactive.

Visual SourceSafe provides the following advantages:

Next are five check boxes that control a few of the features of Visual SourceSafe. The first check box, Automatically Add New Projects to Source Control, does exactly that. Usually, you want to make a conscious decision about when to add a project to VSS. (Simply open the project and choose Add Project to Source Control from the Project drop-down menu.)

The second option, Check Out Files Upon Modification, automatically calls up VSS when you click the Modify button in the Project Manager. Yes, Source Safe still prompts you to check out the file, but the menu comes up automatically and you need only click OK. Otherwise, you must manually check out the file before you attempt to open it; if you don't, the file will be opened as read-only. In either case, you will have to manually check the file back in after editing it.

The third option, Add Files to Source Control Upon Add, automatically puts new project files into VSS. Similarly, the fourth option, Remove Files From Source Control Upon Removal From Project, removes references to the file in VSS when you remove the file from the project. Notice that removing a file from a project does not delete it from disk; neither does it remove all references to the file from the VSS database.

The forth check box, Display Dialog Box for Shortcut Menu Commands, enables you to perform a VSS command from the project shortcut menu on multiple files.

The last option, Text Generation, identifies a file that stores integration information between VFP and VSS. Specifically, the file creates text representations of screen, menu, report, and label files. Currently, you might not have any other alternatives for this utility. Because the source code is provided, however, you can make modifications to the version supplied with VFP. In this case, you probably want to save your revision with a different name and, therefore, need to change the reference here.

Regional Options

Regional options your applications for local date, time, currency, and number conventions for international applications. If you click the first check box, Use System Settings, you cannot make any changes to the settings. Even if you need to make only one change, you must first deselect this box. Figure 1.25 shows the options available for Regional customization.

Figure 1.25: The Regional page of the Options dialog box defines formatting for dates and numbers.

The first customization option, Date Format, controls the format that VFP uses to display the date and time. The default is American, but options exist for many other nations. There is even a difference between American and USA! (Hint: Watch the character between the month, day, and year.) You can even create and save your own custom format by following these steps:

  1. Select the closest Date Format from the drop-down list.
  2. To change the Date Separator, click the check box, and enter a new character.
  3. To turn the display of the century on or off, click the Century check box appropriately. This being only a few short years from the turn of the century, however, you may want to begin writing applications with Century turned on.
  4. To select either a 12-Hour or 24-Hour clock, click the appropriate button. Remember that the suffix AM or PM appears only when you are using the 12-hour clock.
  5. To display seconds, make sure to check the Seconds check box.

For each of these changes, you should see the corresponding result on a sample date and time string in the upper-right corner of this area.

The Currency Format option places the currency symbol either before or after the number. You can set this option programmatically with SET CURRENCY LEFT|RIGHT.

The Currency Symbol field defines the currency symbol. You can use any valid symbol in the current character set, including combinations of up to nine characters. You can set this option with SET CURRENCY TO.

The 1000 Separator symbol appears at every third digit on the left side of the decimal separator when this option is selected. The command SET SEPARATOR performs the same function in programs.

The Decimal Separator symbol separates the whole portion from the fractional portion of a number.

The Decimal Digits value defines the minimum number of decimal places used to show expression results. This value can range from 0 to 18. This option's function is equivalent to SET DECIMALS TO.

Additional options related to date determine the default week start day and the definition of what constitutes the first week of the year.

You can select any day of the week for the Week Starts On option.

The First Week of Year feature has three possible values:

This information determines the value returned by WEEK(). WEEK() can override these default values.

Remote Data Options

The Remote Data options determine how Visual FoxPro establishes connections to remote data and works with remote data views. Figure 1.26 shows the available options.

Figure 1.26: The Remote Data page of the Options dialog box defines how Visual FoxPro establishes connections to remote data.

The first group of options establishes remote view defaults. A remote view is any data file that is not a Visual FoxPro table or database.

In many cases, a single remote ODBC connection enables you to open only a single view. By selecting Share Connection, however, you can open additional views.

Fetching memos across a remote connection can greatly increase network traffic. Therefore, VFP recommends selecting the option Fetch Memo, which retrieves the memo data only if the user activates the field.

Visual FoxPro provides several options for SQL updates. First are four Criteria options that determine whether VFP can update records in the source:

These options determine conditions that enable SQL to succeed. This first one, for example, determines whether any of the key fields have changed in the source table since the data was retrieved. If so, the update fails.

The second SQL update option defines how to update the remote data. Visual FoxPro can perform a SQL Update on the selected records, or it can delete the old records and insert the modified ones by using the Method option.

The Records to Fetch at a Time option also limits traffic across a remote connection: It determines how many records to return from a query at one time. As you move through the records, the connection returns additional blocks of records until all records have been returned or you leave the view.

The Maximum Records to Fetch option places an upper limit on the total number of records returned by a query. You might want to consider using this option during testing, just in case your query incorrectly creates a Cartesian product view.

Some remote tables may support long character fields. The Use Memo for Fields >= option enables VFP to convert these long fields to memos automatically. Remember that a VFP character field supports a maximum 254 characters; therefore, 255 is a good default value for this option.

The Records to Batch Update option defines the number of records sent to the server in a single update statement. You can optimize network traffic if you batch multiple records in each update statement.

The Connection Defaults define how your application communicates with the remote data.

The Asynchronous Execution option determines whether control returns to your application immediately after it sends a SQL pass-through statement. In synchronous operation, control does not return until the entire result set is returned. In asynchronous execution, your application can do other things while it waits for the SQL to complete.

The Display Warnings option determines whether to display error messages during the processing of a remote SQL pass-through.

Batch Processing determines how to retrieve multiple result sets.

The Automatic Transactions option determines whether SQL transactions are handled automatically by Visual FoxPro or whether the application must include its own SQLCOMMIT() and SQLROLLBACK() functions.

Some servers require that the user log in before accessing the data. The Show Login option enables you to determine whether to show the login dialog box: always, never, or only when needed.

Connection Timeout specifies the number of seconds to wait for a connection to be recognized by the server.

Idle Timeout specifies the number of minutes that Visual FoxPro maintains the connection without activity. The default value, 0, requires that the application break the connection.

Query Timeout specifies how long (in seconds) Visual FoxPro waits for a result set to complete from a query before generating an error.

The Wait Time option specifies the number of milliseconds before Visual FoxPro checks to see whether the SQL statement has completed.

Syntax Coloring Options

The Syntax Coloring options enable you to change the colors used to display different types of text while you are working in the Visual FoxPro editor. The use of color makes your programs easier to read. You can to emphasize keywords, variables, or even comments in a different color to help them stand out. Figure 1.27 shows the options for syntax coloring.

Figure 1.27: Make your programs easier to read with syntax coloring.

The types of text or Area that you can color include:

For each type of text, you can select a Font Style from the following:

Finally, you can change the Foreground and Background colors of each text type. The drop-down list displays 16 possible colors, along with Automatic. To make your comments really stand out, for example, make them bold white text on a black or dark-blue background.

View Options

The View options determine how Visual FoxPro uses the status bar, if at all. These options also determine whether to display the recently used file list and whether VFP opens the last project automatically on startup. Figure 1.28 shows these options.

Figure 1.28: The View page of the Options dialog box defines several features of the status bar, as well as whether to track project use.

The Status Bar option controls whether to display the status bar, which appears at the bottom of the screen. When the status bar is not shown, FoxPro displays messages in Wait windows in the upper-right corner of the screen.

To continuously display a clock in the status bar, select the Clock option, which places the current system time in a fourth box at the right end of the status bar.

To display command results in the status bar, click the Command Results option. To see an example of a command result, open and pack a table. The messages in the status bar tell you how many records it has processed and the total number of records are command results. Indexing and reindexing also display messages as part of command results.

The System Messages option enables or disables the display of selected system messages. One example of a system message is Expression is Valid displayed by the Expression Builder when you validate an expression. Another example is the Attempting to lock... message that appears when VFP attempts to obtain a record or file lock in a shared environment. These messages appear in the status bar (when it is present) or in a wait window. This command corresponds to the SET NOTIFY command.

The Recently Used Project List option determines whether to display up to four recently used projects in the File menu.

The last option in this page-Open Last Project on Startup-tells Visual FoxPro to automatically open the last project used before exiting Visual FoxPro on startup the next time.

If you exit Options by clicking OK, the changes that you made affect only the current session. To make changes permanent, click the Set As Default option before you click OK.
If you hold down the Shift key while clicking OK, VFP writes the equivalent SET commands to the Command window. Copy the commands from this window and place them in your code to customize a program's properties.

Getting Help from Visual FoxPro

The last menu pad in the main menu is Help. You can active Help in four primary ways, two of which use this menu directly.

Microsoft Visual FoxPro Help Topics, which appears first in the Help menu, opens the main Help window. VFP uses a page frame type format to display three ways to select help topics. The first tab, Contents, provides an outline-like approach to navigating help by successively drilling down through more detailed levels.

Any time you press F1 with no text highlighted, VFP takes you to the Help Topics window.

The second page of the Help Topics page frame is labeled Index. This option requires a word or phrase that might appear in a help topic title. VFP uses this text string to search the available help topic titles, looking for a match. If VFP finds a match, it displays those topics.

The Find page of the Help Topics page frame lets you search by any keyword or phrase that might appear in the text of the help topics itself. This search requires more time, but it enables you to locate all topics that might use a specific word.

Direct commands provide another way to access help. If you need help on a specific command or function, enter the keyword HELP in the Command window, followed by the command or function, as in this example:


Finally, you can highlight a word in any text-edit window and press F1. VFP copies the word to the Search dialog box. If it matches a topic exactly, VFP immediately displays the topic. Otherwise, VFP pastes the word in the Search dialog-box string area and enables you to select an appropriate topic manually.

The following sections take a closer look at each of the methods.

Searching Help Via Contents

If you choose the Contents page from the Help Topics window, Visual FoxPro displays the top level of Visual FoxPro Help Contents. Figure 1.29 shows the initial screen.

Figure 1.29: The initial screen of the Visual FoxPro Help Contents shows four help categories.

This screen divides help into four topics:

To open one of these topics, click the icon before the category name. Each topic can include additional topic levels. You can continue to drill down through the topics to find more specific information. Figure 1.30 shows the next help level that appears after you click the Language Reference icon.

Figure 1.30: This figure shows the Language Reference topic open along with the Language Content topic showing the Language Reference A-Z topic.

Language Reference consists of four subcategories, beginning with an introduction. Each subcategory is preceded by the icon of a closed book. To open the topic, double-click the book. There can also be books within books. When you reach the level of a document, the icon displays a page with a question mark on it. Double-clicking a page icon opens that specific help topic in a separate window.

Figure 1.31 shows that the Language Reference A-Z option displays a scrollable list of all commands, events, functions, and properties in Visual FoxPro. You can scroll through the list to find the command or function you want.

Figure 1.31: The Language Reference A-Z topic combines a scrolling list with command buttons to help you find a help topic.

Notice the letter buttons at the top of the dialog box. Click one of these buttons to quickly move to the first command or function that begins with that letter. Suppose that you want to get more information on the command WEEK(). First, click the letter W to skip directly to commands and functions that begin with W. Next, scroll to WEEK() and click the function to display its help text. Figure 1.32 shows the help text for WEEK().

Figure 1.32: Help topics contain a brief description, syntax, return types, arguments, and remarks such as those shown for function WEEK().

In any help dialog box, when you click green text with a solid underline, you jump to that topic immediately. Therefore, this type of text is called a jump. Green text with a dotted underline displays a pop-up window that defines the underlined term. A pop-up window can itself have green text with either solid or dotted underlines. To close a pop-up window, click anywhere outside it or press Esc.

Many help topics contain an option called See Also, which appears directly below the topic title. Click this option to display cross-referenced topics. Sometimes, you might not be sure exactly what command you need to look for. But by starting at a command or function that is closely related to the one that you want, you might find it by surfing through these cross-references.

Another common feature of most topics in the Language Reference is examples. If the current help topic contains examples, the word Example also appears in green immediately below the topic title. Click the green Example text string to see sample command lines or even a small program segment that illustrates the command's use. Figure 1.33 shows the examples provided for WEEK().

Figure 1.33: Most commands and functions include examples, like this one for function WEEK().

Notice that this window has both a menu with five options and a button bar with eight buttons. You can reach all the functions listed in the menu by using the buttons. Therefore, the following text reviews only the button options.

The button bar begins with the Contents button, which returns you to the Contents page of the Help Topics window. Similarly, the Index button corresponds to the second page of the page frame, and returns you to the alphabetical listing of all help topics, enabling you to jump to another topic easily. The Find button, corresponding to the third page of the page frame, enables you to refine your help search by entering one or more words related to the help topic that you want to find.

The Back option takes you back to help topics that you looked at previously; it does not make side trips to the Contents, Index, or Find page. To return to these pages, click their buttons directly. The Print option sends the text of the current help topic to your default printer. The << and >> buttons move you backward and forward alphabetically through the help topics.

The Options button opens another menu that contains a series of options. These options include one that enables you to Annotate the current help topic, which means that you can add your own notes to this help topic. Your annotations become associated with the topic, and any user who accesses this help file sees them as well. You can use this feature to further clarify the help text, provide your own examples, or even add references to your favorite FoxPro book.

The Copy option places a complete copy of the current help-topic text in the Clipboard; from there, you can paste it into another document. The Print Topic option provides another way to print the current topic text. Font enables you to change the font. If the current help font is too small to read, you can enlarge it. You can even make the font smaller if you want to see more of the text at one time and don't mind squinting.

If you open an Example window, you must use the Options button in the button bar and choose Copy to place the example code into the Clipboard. From there, you can paste the code into a program file and test it.

The Keep Help on Top option is useful if you want to keep an example (or perhaps the syntax) of a command on the screen while you return to the program and make your changes. Finally, you can set the colors to the help system or revert to the system colors with the Use System Colors option.

Searching for Help Via the Index

If you choose the Index from the Help Topics pageframe VFP displays a dialog that lets you enter the first few letters of the term for which you want to search. You can also use the list to select topics directly. Suppose that you want help on Create Classlib. Just enter create classlib in the first text box. (The search string is not case sensitive.) As you enter each letter, the list below the text box incrementally searches the help topics. The first letter, C, moves down the list to C. The second letter, R, moves further to CREATE. For the balance of the letters in the word create, the list does not change. But when you enter the c in classlib, the list moves again, this time to the topic CREATE CLASS. Only after you type the second L will the highlight move to the desired topic. For any search, you have to enter only enough characters to uniquely identify the topic; you do not have to complete the rest of the search string. You can also use the arrow keys or mouse to highlight the desired topic directly. Finally, click Display to show help on the highlighted topic. Figure 1.34 shows the screen just before it displays the topic.

Figure 1.34: Obtain help by performing a keyword search with Help's Index page, shown here finding the topic CREATE CLASSLIB.

The Index option only searches the help topic names. Sometimes, however, you might need to search for help but you don't know the topic name. In such a case, you want to search based on the help contents rather than the topic name. To do so, choose the Find page of the Help Topics window. Figure 1.35 shows how to search for help based on words contained in the help text rather than in the topic.

Figure 1.35: Conduct a context search of help by using the Find options to locate all topics that contain selected words.

In this dialog box, you can enter a series of words in the first text box (numbered 1) to search for (trigger, in this example), or you can select words from a scrollable list (numbered 2). Notice that after you enter one or more words in the first text box, the second text box shows selected related words to narrow your search. The next list (numbered 3), at the bottom of the dialog box, shows the topics that contain the selected word or words. You can select these topics for display or fine-tune your search with additional words. A text field near the bottom of the dialog box shows the number of topics that currently match the search criteria.

The Options button in this dialog box displays options that enable you to define how to conduct the search. Figure 1.36 shows these options.

Figure 1.36: Customize your context search by telling Help how to use the words and characters that you enter.

You can search for the following:

You also can search for topics that:

Finally, you can have the search begin Immediately After Each Keystroke (incremental search) or After You Click the Find Now Button.

That is all you need to know to use Help effectively. After a little practice, you might find that you can get information from VFP's Help faster than you can from the manuals.

© Copyright, Sams Publishing. All rights reserved.