Article ID: 894818 - Last Review: April 7, 2005 - Revision: 1.2 New directives for the Beautify tool are available in Visual FoxPro 9
INTRODUCTIONMicrosoft Visual FoxPro includes a tool that is named Beautify. The Beautify tool lets you make your code easier to read by providing options to adjust indentation and case. You can globally set these options in the Beautify Options dialog box. These options are used every time that you run the Beautify tool on a code block. However, you may want to override some of these options on a program-by-program basis. You can do this by using Beautify directives. Beautify directives are specially formatted comments put in code blocks. When you run the Beautify tool on a code block and the Beautify tool encounters these Beautify directives, the Beautify tool performs certain actions. MORE INFORMATION The Beautify tool can adjust the case of keywords. Keywords in Visual FoxPro are all the reserved words in the Visual FoxPro programming language. For example, one keyword is MODIFY. You can make a code block easier to read and make elements in a code block easier to identify by adjusting the case of all the keywords in the code block. However, this adjustment may sometimes have unexpected side effects. Although Visual FoxPro is a case-insensitive language, some of the tools you may use are case-sensitive. For example, functions in the Windows API must be declared and called in a case-sensitive manner from Visual FoxPro. A Beautify-related problem occurs when you use a function from the Windows API that shares the same name as a Visual FoxPro keyword. A specific example of a Visual FoxPro keyword that shares the same name as a function from the Windows API is the Visual FoxPro ShowWindow property. When the Beautify tool encounters this Visual FoxPro keyword, the Beautify tool adjusts the case of that keyword based on the settings in the Beautify Options dialog box. To successfully call the Windows API ShowWindow function, Visual FoxPro code must be specifically formatted in Pascal case. References to the Visual FoxPro ShowWindow property can be formatted in any case you want, because Visual FoxPro is case-insensitive. The Beautify tool cannot tell if an occurrence of the keyword ShowWindow in a code block is a reference to the Visual FoxPro property or to the function from the Windows API. If the reference is to the function from the Windows API and if the Beautify tool changes the case of the code, the call to the function will fail when the Visual FoxPro code runs. In versions of Visual FoxPro earlier than Visual FoxPro 9.0, there was no easy way to prevent the Beautify tool from making this case adjustment. Visual FoxPro 9.0 introduces two new Beautify directives to help resolve this problem:
Note These directives take the form of comments. The directives are preceded by an asterisk (*) character. An asterisk (*) character is the default character for full-line comments in Visual FoxPro. This comment format is required for the directive to work. A benefit of this comment format is that even though the directive is only recognized by the Beautify tool in Visual FoxPro 9.0 and later versions, the code will continue to compile in versions of Visual FoxPro earlier than Visual FoxPro 9.0. The following example demonstrates how to use these Beautify directives in Visual FoxPro 9.0 and later versions:
Block 2 does not contain the Beautify directives. Therefore, in Block 2 the ShowWindow keyword is changed to uppercase. This change makes the code block not valid. To verify this, save and then run the code. When you run the code, the following error will be thrown on the DECLARE line in Block 2: Error 1754: Cannot find entry point SHOWWINDOW in the DLL. | Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|





















Back to the top