常量命名约定
备注
推荐常量以大写字母表示。
示例
#DEFINE MAX_VALUE 10
变量命名约定
[Scope]TypeName
参数
Scope
可选。为标注变量作用范围的命名习惯。例如,局部变量使用“l”前缀,它提醒你它们仅作用于被定义的程序内部。建议的 Scope 表达式如下:
Scope |
描述 |
示例 |
l |
Local |
lnCounter |
p |
Private (default) |
pnStatus |
g |
Public (global) |
gnOldRecno |
t |
Parameter |
tnRecNo |
Type
标注变量数据类型的习惯。建议的 Type 前缀如下:
Type |
描述 |
示例 |
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 |
备注
前缀不是必须的,但是推荐这种好的编程习惯。使用前缀并不能规定变量的取值 — 在 Visual FoxPro 中,前缀仅仅作为一种命名的习惯。例如,增加前缀“c”并不能规定仅字符数据可以存储在该变量中, 但它可以提醒该变量是作为接受字符数据而建立的。
注意 scope 前缀仅是推荐而不是必须的。在某些情况下,范围不一定很明确。例如,在一个独立应用的主程序中,PUBLIC 或 PRIVATE 定义的变量可见范围没有区别。类型前缀永远与示例程序相关。
对象命名约定
PrefixName
推荐的对象命名前缀在下表中列出。
前缀 |
对象 |
示例 |
chk |
CheckBox |
chkReadOnly |
col |
Collection |
colFormObjects |
cbo |
ComboBox |
cboEnglish |
cmd |
CommandButton |
cmdCancel |
cmg |
CommandGroup |
cmgChoices |
cnt |
Container |
cntMoverList |
ctl |
Control |
ctlFileList |
cad |
CursorAdapter |
cadInventory |
|
Custom |
user-defined |
dte |
DataEnvironment |
dteSalesForm |
edt |
EditBox |
edtTextArea |
frm |
Form |
frmFileOpen |
frs |
FormSet |
frsDataEntry |
grd |
Grid |
grdPrices |
grc |
Column |
grcCurrentPrice |
grh |
Header |
grhTotalInventory |
hpl |
HyperLink |
hplHomeURL |
img |
Image |
imgIcon |
lbl |
Label |
lblHelpMessage |
lin |
Line |
linVertical |
lst |
ListBox |
lstPolicyCodes |
olb |
OLEBoundControl |
olbObject1 |
ole |
OLE |
oleObject1 |
opt |
OptionButton |
optFrench |
opg |
OptionGroup |
opgType |
pag |
Page |
pagDataUpdate |
pgf |
PageFrame |
pgfLeft |
prj |
ProjectHook |
prjBuildAll |
sep |
Separator |
sepToolSection1 |
shp |
Shape |
shpCircle |
spn |
Spinner |
spnValues |
txt |
TextBox |
txtGetText |
tmr |
Timer |
tmrAlarm |
tbr |
ToolBar |
tbrEditReport |
xad |
XMLAdapter |
xadRemoteXMLData |
xfd |
XMLField |
xfdPrices |
xtb |
XMLTable |
xtbInventory |
备注
前缀不是必须的,但是推荐这种好的编程习惯。使用前缀并不能规定变量的取值 — 在 Visual FoxPro 中,前缀仅仅作为一种命名的习惯。例如,增加前缀“cbo”并不能规定对象是一个组合框,但它可以提醒该对象是一个组合框。
表字段命名约定
Alias.TypeName
参数
Type
标记表字段的数据类型。建议 Type 的前缀如下表。
类型 |
描述 |
示例 |
c |
字符 |
Customer.cLastName |
d |
日期 |
Customer.dBirthDay |
t |
日期时间 |
Customer.tLastMod |
b |
双精度 |
Customer.bRate |
f |
浮点 |
Customer.fValue |
g |
通用 |
Customer.gPicture |
l |
逻辑 |
Customer.lSellMail |
m |
备注 |
Customer.mComments |
y |
货币 |
Customer.yYearTDate |
n |
数值 |
Customer.nItems |
I |
整型 |
Customer.iCustID |
备注
前缀不是必须的,但是推荐这种好的编程习惯。使用前缀并不能规定变量的取值 — 在 Visual FoxPro 中,前缀仅仅作为一种命名的习惯。例如,增加前缀“c”并不能规定仅字符数据可以存储在该变量中, 但它可以提醒该变量是作为接受字符数据而建立的。
窗口命名约定
wName
备注
不要在类定义前使用前缀;仅当示例的对象才使用前缀。
示例
当建立窗口对象时使用下列代码:
DEFINE WINDOW wCustomerInvoices ;
FROM nFirstRow, nFirstColumn TO nLastRow, nLastColumn