How to: Display and Print Source Code in Color

You can display and print code with color syntax in the Command window and Visual FoxPro editors for program (.prg) files, methods, stored procedures, and memos.

The following sections contain more information about displaying and printing code in color:

  • Displaying Source Code in Color

  • Printing Source Code in Color

Displaying Source Code in Color

You can turn on syntax coloring separately for each editing window; however; the color syntax settings that you choose in the Editor tab of the Options dialog box apply to the Command window and most other editing windows. For more information, see Editor Tab, Options Dialog Box and Editing Window.

Note

To display color syntax in run-time applications, Visual FoxPro must be configured to display color syntax. Run-time applications display only the default color settings because run-time applications do not check the Windows registry for settings that you change in the Options dialog box, which specifies the default settings for color syntax.

When color syntax is turned on, Visual FoxPro performs background compilation for the current and single line of code that you are typing. When a line of code contains invalid syntax, Visual FoxPro displays the line of code with the selected formatting style.

To display color syntax in an editing window

  1. Open the editing window that you want to display color syntax.

  2. On the Edit menu, choose Properties.

  3. In the Edit Properties dialog box, select the Syntax coloring check box.

  4. Click OK.

Syntax coloring is activated for the editing window you selected. For more information, see Edit Properties Dialog Box.

You can also display source code files to the screen in color using the TYPE command. For more information, see TYPE Command.

To customize color syntax settings

  1. On the Tools menu, choose Options.

  2. In the Options dialog box, choose the Editor tab.

  3. Under Syntax color settings, choose the color settings that you want.

  4. When you are finished choosing settings, click OK.

The color settings you chose take effect.

To set formatting for invalid color syntax

  1. Turn on syntax coloring for the editing window.

  2. On the Tools menu, choose Options.

  3. In the Options dialog box, choose the Editor tab.

  4. In the Background Compile box, choose the formatting style you want.

Invalid syntax displays in the editing window with the formatting style you chose.

Printing Source Code in Color

You can print source code in color wherever color syntax appears, such as program files, methods, stored procedures, and memos.

Note

To print your code files in color, you must be connected to a color printer to select the color printing options available for your printer. Background colors set in the Editor tab of the Options dialog box are not printed. If you select color printing for source code files, hyperlinks appear underlined.

To print source code in color

  1. Open the program file or code you want to print.

  2. On the File menu, choose Print.

  3. In the Print dialog box, choose your color printer, and then click Preferences.

  4. Select the color printing options available for your printer.

  5. When you are finished, click Print.

When connected to a color printer, you can also print source code in color using the TYPE command with the TO PRINTER clause.

For more information, see Print Dialog Box (Visual FoxPro) and TYPE Command.

See Also

Tasks

How to: Set Editor Options
How to: View and Change Environment Settings

Other Resources

Visual FoxPro Environment Settings