Recommended Naming Conventions for Visual FoxProLast reviewed: April 30, 1996Article ID: Q129977 |
The information in this article applies to:
SUMMARYFor consistency, readability, and making troubleshooting a little easier, standard naming conventions should be used in programming. Some naming conventions are required for sample code. This article gives the recommended standard naming conventions for constants, variables, objects, tables, and windows in Visual FoxPro. This information is available in Help by typing the following in the Command Window:
HELP naming conventions MORE INFORMATION
Constant Naming Conventions
Syntax: NAMEExample: #DEFINE MAX_VALUE 10 Render constants in all uppercase letters.
Variable Naming Conventions
Syntax: [Scope]TypeNameThe Scope prefix is recommended but not required. In some cases, explicit scoping does not apply. For example, in the main program of a stand-alone application, there is no difference in visibility for variables scoped as PUBLIC or PRIVATE. Scope specifies the range of reference for the variable. For example, local variables can be referenced only within the procedure that defines them. Public variables are accessible from anywhere in the application. The choices for Scope are:
Scope Description Example --------------------------------------- l Local lnCounter p Private (default) pnStatus g Public (global) gnOldRecno t Parameter tnRecNoThe Type prefix is always relevant and is required in sample programs. Type specifies the data type for the variable. The choices for Type are:
Type Description Example ----------------------------------- a Array aMonths c Character cLastName y Currency yCurrentValue d Date dBirthDay t Datetime tLastModified b Double bValue f Float fInterest l Logical lFlag n Numeric nCounter o Object oEmployee u Unknown uReturnValue Object Naming ConventionsSyntax: PrefixName Follow this suggested format for naming objects. The choices for Prefix are:
Prefix Object Example --------------------------------------------------- chk check box chkReadOnly cbo ComboBox cboEnglish cmd CommandButton cmdCancel cmg CommandGroup cmgChoices cnt Container cntMoverList ctl Control ctlFileList <user-defined> Custom user-defined edt EditBox edtTextArea frm Form frmFileOpen frs FormSet frsDataEntry grd Grid grdPrices grc Column grcCurrentPrice grh Header grhTotalInventory img Image imgIcon lbl Label lblHelpMessage lin Line linVertical lst list box lstPolicyCodes olb OLEBoundControl olbObject1 ole OLE oleObject1 opt OptionButton optFrench opg OptionGroup opgType pag Page pagDataUpdate pgf PageFrame pgfLeft sep Separator sepToolSection1 shp Shape shpCircle spn Spinner spnValues txt text box txtGetText tmr Timer tmrAlarm tbr ToolBar tbrEditReport Table Field Naming Conventions
Syntax: Alias.TypeNameArguments: Type Follow this suggested format for naming fields in tables. These conventions are recommended, not required. Type specifies the data type for a field in a table. The choices for Type are:
Type Description Example ------------------------------------- c Character Customer.cLastName d Date Customer.dBirthDay t Datetime Customer.tLastMod b Double Customer.bRate f Float Customer.fValue g General Customer.gPicture l Logical Customer.lSellMail m Memo Customer.mComments y Currency Customer.yYearTDate n Numeric Customer.nItems i Integer Customer.iCustID Window Naming Conventions
Syntax: wNameExample: DEFINE WINDOW wCustomerInvoices ; FROM nFirstRow, nFirstColumn TO nLastRow, nLastColumnFollow this suggested format for naming windows. Do not use a prefix on class definitions. Use prefixes only when the object is instantiated.
|
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |