vfp常用函数

合集下载

VFP常用函数总汇

VFP常用函数总汇

VFP常用函数总汇VFP常用函数总汇VFP常用函数使用说明1、数值运算函数函数操作例结果SQRT(x) 求平方根 SQRT(9) 3INT(x) 取整数 INT(3.14) 3ROUND(x) 四舍五入 ROUND(3.14159,4) 3.1416MOD(x,y) 求X除以Y的余数 MOD(25,4) 1MAX(x,y) 求X,Y中的最大值 MAX(7,8) 8MIN(x,y) 求X,Y中的最小值 MIN(1,2,3) 12、字符中操作函数函数名操作例结果UPPER(S)小写字母 UPPER(abc) ABCLOWER(S)大写字母 LOWER(ACD) acdLEN(S)求字符串的长度 LEN("中国1号") 7AT(S1,S2)在字符串S2,找字符串S1 AT("H","CHINA") 2SUBSTR(S,I,N)在S字符串中的第I个字符起取N个字符SUBSTR('TECHNOLO',3,3) CHNLEFT(S,N)从字符串S左边取N个字符 LEFT(“中国人”,4)中国RIGHT(S,N)从字符串S右边取N个字符S=‘12345’RIGHT(S,3) 345SPACE(N)生成N个空格 "合计"+SPACE(2)+"123" 合计123 TRIM(S)消除字符串尾部空格 TRIM("姓名 ") 姓名ALLTRI(S)消除字符串中所有空格 ALLTRIM("李丽")李丽STUFF(S1,N1,N2,S2) 用字符串S2替换S1中第N1个字符起的N2个字符 STUFF("NOW",2,1,"E") NEW& 宏替换P=“G2”USE &P USE G23、日期和时间函数函数名操作例结果DATE()求当前日期 DATE() 2001/11/12DATETIME() 求当前日期和时间 DATETIME() 2001/11/12/0:22:33amYEAR(D)求年份 YEAR(DATE()) 2001MONTH(D)求月份(数值) MONTH(DATETIME()) 11CMONTH(D)求月份(字符)MONTH(DATETIME()) NovenberDAY(D)求日期 DAY(DATE()) 12DOW(D)求星期几(数值) DOW(DATE()) 1CDOW(D)求星期几(英文) CDOW(DATE()) sundayTIME(D)求当前时间 TIME(DATE()) 10:20:38am4、数据类型转换函数函数名操作例结果ASC(S)求第一个字符串的ASCII码 ASC("what") 87CHR(N)求ASCII码的字符 CHR(87) wSTR(R,L,D) 数值转换成字符,L为长度,D为小数位数 X=3.1415STR(X,6,2) 3.14VAL(S)字符串转换为数值 VAL("123") 123.00CTOD(S)字符串转日期 CTOD('11/01/2002') 11/01/2002DTOC(D)日期转换成字符串 DTOC(DATE()) 11/01/2002DTOS(D)把日期转成年月日式的字符串DTOS(DATE()) 20021101CTOT(C)字符串转成日期时间型CTOT(11/01/2002 10:30:50am) 11/01/2002 10:30:50amDTOT(D)日期型转为日期时间型DTOT(DATE()) 11/25/2001 00:00:01amTTOC(T)日期时间型转为字符型TTOC(DATETIME()) 11/25/2001 00:00:01amTTOD(T)日期时间型转为日期型TTOD(DATETIME()) 11/25/2001IIF(LE,E1,E2) 逻辑判断 IIF(A>0,"YES","NO") YES5、检测函数函数名操作例结果RECNO()检测当前记录号 RECNO() 1RECCOUNT()检测当前记录数 RECCOUNT() 12BOF()开始记录 BOF() 1EOF()最后记录 EOF() 12FOUND()返回查找结果 FOUND() .T.ROW()返回当前行坐标 ROW() 1COL()返回当前列坐标 COL() 1SYS(N)返回系统状态 SYS(13)联机状态。

vfp常用函数

vfp常用函数

Visual FoxPro常用函数分类表2008-02-16 19:44VisualFoxPro磁盘_目录_文件函数ADIR()将文件信息存放到数组中,然后返回文件个数。

CURDIR()返回当前目录或文件夹。

DEFAULTEXT()如果一个文件没有扩展名,则返回一个带新扩展名的文件名。

DIRECTORY()若在磁盘上存在指定的目录,返回真(.T.)。

DISPLAYPATH()为显示而截去长路径名到指定长度。

DRIVETYPE()返回指定驱动器的类型。

FDATE()返回文件最近一次修改的日期或日期时间。

FILE()如果在磁盘上找到指定的文件,则返回“真”(.T.)。

FILETOSTR()将一个文件的内容返回为一个字符串。

FORCEEXT()返回一个字符串,使用新的扩展名替换旧的扩展名FORCEPATH()返回一个文件名,使用新路径名代替旧文件名FTIME()返回最近一次修改文件的时间。

FULLPATH()返回指定文件的路径或相对于另一文件的路径。

GETDIR()显示“选择目录”对话框,从中可以选择目录或文件夹。

GETFILE()显示“打开”对话框,并返回选定文件的名称。

JUSTDRIVE()从完整路径中返回驱动器的字母。

JUSTEXT()从完整路径中返回三字母的扩展名。

JUSTFNAME()返回完整路径和文件名中的文件名部分。

JUSTPATH()返回完整路径中的路径名。

JUSTTEM()返回完整路径和文件名中的根名(扩展名前的文件名)。

LOCFILE()在磁盘上定位文件并返回带有路径的文件名。

PUTFILE()激活“另存为…”对话框,并返回指定的文件名。

STRTOFILE()将一个字符串的内容写入一个文件。

SYS(3)返回一个合法文件名,可用来创建临时文件。

SYS(5)返回当前VisualFoxPro的默认驱动器。

SYS(7)返回当前格式文件的名称。

SYS(2000)返回一个按字母排序的与文件名和扩展名梗概匹配的第一个文件名。

VFP_函数

VFP_函数

数值函数1、INT函数(取整函数)格式:INT(数值表达式) 功能:求数值表达式值的整数部分。

例如:int(-18.567)的返回值为–18 int(-18.123) 的返回值亦为–182、MAX函数格式:MAX(表达式1,表达式2,…,表达式n)功能:求n个表达式中的最大值。

例如:a=2 b=15 c=9 时max(a,b,c) 的返回值为15a=’辽河’b=”淮河” c=[湘江] 时max(a,b,c,) 的返回值为湘江a= {^1997-07-01} b={^2001-12-20} c={^2001-07-13} 时max(a,b,c) 的返回值为07/13/01相似函数:MIN(表达式1,表达式2…表达式n),求n个表达式中的最小值。

3、MOD函数(取余函数)格式:MOD(数值表达式1,数值表达式2)功能:求数值表达式1除以数值表达式2的余数。

与运算符”%”的功能完全相同。

说明:数值表达式2不为0;大于0时函数返回正数;小于0时函数返回负数。

当两数值表达式的数值正负相异时,返回值为“余数+数值表达式2”例如:mod(18,5) 返回值 3 mod(-18,-5) 返回值-3 mod(18,-5) 返回值-2 (20-2)/(-5)==(-4)…(-2)mod(-18,5) 返回值 2 (-20+2)/5==(-4) (2)字符型函数1. & (宏替换)宏替换是FoxPro中一个非常重要的功能;从形式上看,&不象一个函数,更象一个运算符。

格式:&内存变量名[.字符表达式]功能:把字符型内存变量的当前值替换到&函数出现的位置上注意:圆点表示接在内存变量当前值的尾部如:在命令窗口依次执行下列命令:cc=’科技’ && 为字符型内存变量cc赋值’科技’bb=’&cc.大学’&& 为字符型内存变量bb赋值’科技大学’aa=’中国北京&bb’&& 为字符型内存变量aa 赋值? aa && 屏幕上显示aa的内容: 中国北京科技大学假设X=1Y=2Z=[X+Y]? &Z 输出结果为 32. LEN函数格式:LEN(字符表达式)功能:返回字符表达式中字符串的长度,若为空串,返回数值0。

Visual foxpro 函数大全

Visual foxpro 函数大全

一、 数值函数数值函数用于数值运算,其自变量与函数都是数值型数据。

1.取绝对值函数ABS( )【格式】ABS(<nExp>)【功能】计算nExp的值,并返回该值的绝对值。

2.指数函数EXP( )【格式】EXP(<nExp>)【功能】求以e为底、nExp值为指数的幂,即返回ex的值。

3.取整函数INT( )【格式】INT(<nExp>)【功能】计算nExp的值,返回该值的整数部分。

4.上界函数CEILING( )【格式】CEILING(<nExp>)【功能】计算nExp的值,返回一个大于或等于该值的最小整数。

5.下界函数FLOOR( )【格式】FLOOR(<nExp>)【功能】计算nExp的值,返回一个小于或等于该值的最大整数。

6.自然对数函数LOG( )【格式】LOG(<nExp>)【功能】求nExp的自然对数。

nExp的值必须为正数。

7.常用对数函数【格式】LOG10(<nExp>)【功能】求nExp的常用对数。

nExp的值必须为正数。

8.平方根函数SQRT( )【格式】SQRT(<nExp>)【功能】求非负nExp的平方根。

9.最大值函数MAX( )和最小值函数MIN( )【格式】MAX(<nExp1>,< nExp2>[,< nExp3>...])MIN(<nExp1>,< nExp2>[,< nExp3>...])【功能】返回数值表达式中的最大值MAX( )和最小值MIN( )。

10.求余数函数MOD( )【格式】MOD(<nExp1>,<nExp2>)【功能】返回nExp1除以nExp2的余数。

余数的小数位数与nExp1相同,符号与nExp2相同。

11.四舍五入函数ROUND( )【格式】ROUND(<nExp1>,< nExp2>)【功能】返回nExp1四舍五入的值, nExp2表示保留的小数位数。

foxpro常用函数

foxpro常用函数

一、数值函数数值函数用于数值运算,其自变量与函数都是数值型数据。

1.取绝对值函数ABS( )【格式】ABS(<nExp>)【功能】计算nExp的值,并返回该值的绝对值。

2.指数函数EXP( )【格式】EXP(<nExp>)【功能】求以e为底、nExp值为指数的幂,即返回ex的值。

3.取整函数INT( )【格式】INT(<nExp>)【功能】计算nExp的值,返回该值的整数部分。

4.上界函数CEILING( )【格式】CEILING(<nExp>)【功能】计算nExp的值,返回一个大于或等于该值的最小整数。

5.下界函数FLOOR( )【格式】FLOOR(<nExp>)【功能】计算nExp的值,返回一个小于或等于该值的最大整数。

6.自然对数函数LOG( )【格式】LOG(<nExp>)【功能】求nExp的自然对数。

nExp的值必须为正数。

7.常用对数函数【格式】LOG10(<nExp>)【功能】求nExp的常用对数。

nExp的值必须为正数。

8.平方根函数SQRT( )【格式】SQRT(<nExp>)【功能】求非负nExp的平方根。

9.最大值函数MAX( )和最小值函数MIN( )【格式】MAX(<nExp1>,< nExp2>[,< nExp3>...])MIN(<nExp1>,< nExp2>[,< nExp3>...])【功能】返回数值表达式中的最大值MAX( )和最小值MIN( )。

10.求余数函数MOD( )【格式】MOD(<nExp1>,<nExp2>)【功能】返回nExp1除以nExp2的余数。

余数的小数位数与nExp1相同,符号与nExp2相同。

11.四舍五入函数ROUND( )【格式】ROUND(<nExp1>,< nExp2>)【功能】返回nExp1四舍五入的值,nExp2表示保留的小数位数。

VFP常用函数大全

VFP常用函数大全

VFP常用函数大全一.字符及字符串处理函数:字符及字符串处理函数的处理对象均为字符型数据,但其返回值类型各异.1.取子串函数:格式:substr(c,n1,n2)功能:取字符串C第n1个字符起的n2个字符.返回值类型是字符型. 例:取字符串中的姓.store "王小风" to xm ?substr(xm,1,2) 结果为:王2.删除空格函数:以下3个函数可以删除字符串中的多余空格,3个函数的返回值均为字符型.trim(字符串):删除字符串的尾部空格alltrim(字符串):删除字符串的前后空格ltrim(字符串):删除字符串的前面的空格例:去掉第一个字符串的尾空格后与第二个字符串连接store "abcd " to x store "efg" to y ?trim(x)+yabcdefg 3.空格函数: 格式:space(n)说明:该函数的功能是产生指定个数的空格字符串(n用于指定空格个数).例:定义一个变量dh,其初值为8个空格store space(8) to dh 4.取左子串函数:格式:left(c,n) 功能:取字符串C左边n个字符. 5.取右子串函数:格式:right(c,n) 功能:取字符串c右边的n个字符例:a="我是中国人"?right(a,4) 国人?left(a,2) 我6.empty(c):用于测试字符串C是否为空格.7.求子串位置函数:格式:At(字符串1,字符串2) 功能:返回字符串1在字符串2的位置例:?At("教授","副教授") 2 8.大小写转换函数: 格式: lower(字符串)upper(字符串)功能:lower()将字符串中的字母一律变小写;upper()将字符串中的字母一律变大写例:bl="FoxBASE" ?lower(bl)+space(2)+upper(bl) foxbaseFOXBASE 9.求字符串长度函数: 格式:len(字符串) 功能:求指定字符串的长度例:a="中国人" ?len(a) 6 二.数学运算函数: 1.取整函数:格式:int(数值) 功能:取指定数值的整数部分. 例:取整并显示结果?int(25.69)25 2.四舍五入函数: 格式:round(数值表达式,小数位数)功能:根据给出的四舍五入小数位数,对数值表达式的计算结果做四舍五入处理例:对下面给出的数四舍五入并显示其结果?round(3.14159,4),round(2048.9962,0),round(2048.9962,-3)3.1416 2049 2000 3.求平方根函数: 格式:sqrt(数值)功能:求指定数值的算术平方根例:?sqrt(100) 10 4.最大值、最小值函数: 格式:Max(数值表达式1,数值表达式2)Min(数值表达式1,数值表达式2)功能:返回两个数值表达式中的最大值和最小值例:x1=123.456 x2=234.567?max(x1,x2) 234.567 ?min(x1,x2) 123.456 5.求余数函数:格式:mod(表达式1,表达式2)功能:求表达式1对表达式2的余数例:?mod(10,3)1 6.求指数、对数函数: 格式: exp(数值表达式) log(数值表达式) 功能:(1).exp()计算自然数e为底,表达式的值为指数的幂(2).log()计算表达式值的自然对数,返回lnx的值. 例: x=1 y=exp(x)?exp(x),log(x) 2.72 1 三.转换函数: 1.数值转数字字符串函数:格式:str(n,n1,n2) 功能:将数值n转换为字符串,n1为总长度,n2为小数位例:?str(321.56) 322 &&隐含四舍五入取整转换为字符型数据?str(321.56,6,2) 321.56 2.字符转数值函数: 格式:val(s)功能:将数字字符串s转换为数值例:x="23" y="76" ?val(x)+val(y) 1003.字符转日期函数: 格式:ctod(c) 功能:将日期字符串c 转换为日期例:set dateansi &&日期格式设为美国标准化协会格式?ctod("^2005.11.14")2005.11.14 4.日期转字符函数: 格式:dtoc(d) 功能:将日期d转化为日期字符串例:将日期型数据转化为字符型日期数据并显示汉字日期. set century on&&开启世纪前缀,即日期中年份用4位表示set date ansirq={^2005.11.14} rq=dtoc(rq)?substr(rq,1,4)+"年"+substr(rq,6,2)+"月"+substr(rq,9,2)+"日"2005年11月14日5.时间转字符函数: 格式:ttoc(时间) 功能:将时间转为时间字符串6.字符转时间函数: 格式:ctot(c) 功能:将时间字符串转化为时间7.字符串替换函数:格式:stuff(<字符表达式1>,<起始位置>,<字符个数>,<字符表达式2>)功能:从指定位置开始,用<表达式2>的值去替换<表达式1>中指定个数字符.若<字符个数>为零,直接插入;若<表达式2>为空字符串,则删除<表达式1>中指定个数的字符.例:X="祝大家新年好!" ?stuff(X,7,4,"春节") 祝大家春节好?stuff(X,11,0,"春节") 祝大家新年春节好?stuff(x,7,4," ")祝大家好8.字符转ASCⅡ码函数: 格式:Asc(<字符表达式>)功能:把<字符表达式>左边第一个字符转成相应的ASC Ⅱ码值例:x="Foxpro"?Asc(x),Asc(lower(x)) 70 102 9.ASCⅡ码值转字符函数:格式:chr(数值表达式) 功能:把数值转成相应的ASCⅡ码字符,返回值为字符型例:?chr(70)+chr(111)+chr(111+9) Fox四.日期函数: 1.系统日期函数: 格式:date()功能:给出系统的当前日期,返回值是日期型数据.例:显示系统日期?date() 11/14/05 set date ansi setcentury on ?date() 2005.11.14 2.年、月、日函数:格式1).year(日期表达式):从日期表达式中返回一个由四位数字表示的年份.(2).month(日期表达式):从日期表达式中返回一个用数字表示的月份.(3).day(日期表达式):从日期表达式中返回一个用数字表示的日数. 例:测试系统日期rq=date() ?year(rq),month(rq),day(rq) 2005 11 143.系统时间函数: 格式:time() 功能:得到当前时间字符串例:?time()20:32:26 4.系统日期时间函数: 格式:datetime() 功能:得到当前日期时间例:?datetime() 2005.11.14 08:35:12 PM 5.星期函数:格式:dow(日期表达式) cdow(日期表达式)功能:dow用数字表示星期,1表示星期日,7为星期六;cdow用英文表示星期例:?date()2005.11.15 ?dow(date()),cdow(date()) 3 Tuesday五.测试函数: 1.测试文件尾函数: 格式:eof([n]) 说明:(1).n指定被测工作区号,其围为1~32767(2).该函数用于测试指定工作区中的表的记录指针是否指向文件尾,是则返回真值;否则返回假值;省略可选项指当前工作区.例:测试文件记录指针是否指向文件尾use 职工档案go bottom ?eof() .F.skip ?eof() .T. 2.测试文件头函数: 格式:bof([n]) 说明:(1).n指定被测工作区号,其围为1~32767(2).用于测试指定工作区中的表的记录指针是否指向文件头,是则返回真值;否则返回假值;省略可选项指当前工作区.例:测试记录指针是否指向文件头use 职工档案go top ?bof() .f. skip -1?bof() .t. 3.测试当前记录号函数: 格式:recno() 功能:得到当前的记录号例:use 职工档案?recno() 1 skip ?recno() 24.测试表文件记录数函数: 格式:reccount() 功能:得到表的记录数例:测试"职工档案"表的记录数use 职工档案?reccount() 5 5.测试表字段数函数:格式:fcount() 功能:得到当前的字段数例:测试"职工档案"表共有多少个字段use职工档案?fcount() 9 6.测试查找记录是否成功函数: 格式:found()功能:测试find、seek和locate命令查找记录是否成功.如成功则返回真值,否则为假值.例:在"职工档案"表中查找"小刚"的文化程度use 职工档案locate for ="小刚"?found() .t. display 7.文件测试函数: 格式:file(字符表达式)功能:测试字符表达式指定的文件是否存在例:?file("e:\myvfp\职工档案.dbf".t. 8.数据类型测试函数: 格式:type(字符表达式)功能:测试表达式的数据类型,返回大写字母:N(数值)、C(字符)、L(逻辑)、D(日期)、M(备注)例:x=1236 y="hello" ?type("x" N ?type("y" C9.测试工作区函数: 格式:select() 功能:返回当前工作区的区号10.测试别名函数:格式:alias() 功能:测试当前工作区的别名例: select 1 use 职工档案alias zgda select 2 use 工资情况?alias() 工资情况&&打开表时,不指定别名,表名即为别名select zgda &&通过别名选择工作区?select() 1 11.表文件名函数: 格式:dbf() 功能:返回当前工作区打开的表名例: use 工资情况?dbf() e:\myvfp\工资情况六.其它函数: 1.宏替换函数: 格式:&变量名说明:vfp中只有宏替换函数没有括号.功能是返回指定字符型变量中所存放的字符串.例:为"工资情况"表中每个人加100元工资gz="工资" use 工资情况replace all&gz with &gz+100 2.条件函数: 格式:iif(表达式,表达式1,表达式2)功能:若表达式值为真,则返回表达式1的值;否则返回表达式2的值;函数返回值类型与表达式1或表达式2类型一致a=3 b=5 ?iif(a>b,"高兴","开心") 开心3.消息框函数:格式:messagebox(提示文本[,对话框类型[,对话框标题文本]]) 功能:显示提示对话框说明: (1)对话框类型见表1: 对话框类型功能0仅"确定"按钮1"确定"和"取消"按钮2"终止","重试"和"忽略"按钮3"是","否"和"取消"按钮4"是"和"否"按钮5"重试"和"取消"按钮16stop图标32?图标48!图标64i图标0默认第1个按钮256默认第2个按钮512默认第3个按钮(2).返回值见表2: 返回值按钮1确定2取消3终止4重试5忽略6是7否例:分析messagebox("您确实要退出系统吗?",4+64,"提示信息")会弹出什么样的窗口.分析:回头观察此函数的格式,弹出的对话框中的提示文本是"您确实要退出系统吗",对话框标题是"提示信息",函数中间有"4+64",其中4指定对话框中出现"是"和"否"两个按钮(见表1),64指定对话框中出现i图标(见表2)ok,我们在命令窗口依次执行下列命令:tui=messagebox("您确实要退出系统吗?",4+64,"提示信息")&&变量tui用于接收messagebox函数的返回值,弹出的窗口如图1 ?tui&&变量tui值取决于运行时用户点了哪个按钮,如果点了"是",返回6,如果点了"否",返回7,见表2功能:测试字符表达式指定的文件是否存在例:?file("e:\myvfp\职工档案.dbf").t. 8.数据类型测试函数: 格式:type(字符表达式)功能:测试表达式的数据类型,返回大写字母:N(数值)、C(字符)、L(逻辑)、D(日期)、M(备注)例:x=1236 y="hello" ?type("x") N ?type("y") C9.测试工作区函数: 格式:select() 功能:返回当前工作区的区号10.测试别名函数:格式:alias() 功能:测试当前工作区的别名例: select 1 use 职工档案alias zgda select 2 use 工资情况?alias() 工资情况&&打开表时,不指定别名,表名即为别名select zgda &&通过别名选择工作区?select() 1 11.表文件名函数: 格式:dbf() 功能:返回当前工作区打开的表名例: use 工资情况?dbf() e:\myvfp\工资情况? 在下一行显示表达式串?? 在当前行显示表达式串... 将数据按用户设定的格式显示在屏幕上或在打印机上打印ACCEPT 把一个字符串赋给存变量APPEND 给数据库文件追加记录APPEND FROM 从其它库文件将记录添加到数据库文件中AVERAGE 计算数值表达式的算术平均值PACK 彻底删除加有删除标记的记录ZAP 删除当前数据库文件的所有记录(不可恢复)页脚。

Vfp教程 常用函数

Vfp教程 常用函数
日期和时间函数
Date()
Time ()
Datetime ()
YEAR()
HOUR()时间
四、数据类型的转换
数值转换成字符串STR()
字符串转换成数值VAL()
字符串转换成日期CTOD()
日期转换成字符串DTOC()
日期时间转换成字符串TTOC()
宏替换&
五、测试函数
数值函数
测试数据类型:
ABS(绝对值)
BOF()表头测试
SKIP记录转跳
EOF()表尾测试
Recno()记录号测试
Reccount()记录个数测试
Iff()条件测试
Deleted()删除函数测试
Sign(测试表达的符号,正则返回1。负则返回-1,0则返回0)
Pi()圆周率
Int()返回整数部分
Ceiling()返回大于或等于指定数值的最小整数
Floor()返回小于或等于指定数值的最大整数
Between()测试有没有在中间
IsNull()测试是否是空值
Empty ()空值
VarType()数据类型测试函数
Vfp教程
三、常用函数
ABS()绝对()求整数
ROUND(x,3)四舍五入
MOD()求余数
Mod(10,3)=1 , MOD(-10,3)=2 ,mod(10,-3)=- 2
LEN()求字符的长度
LOWER()小写的转换
UPPER()大写的转换
TRIM()去除尾部空格
LTRIM()去除前面空格
ALLTRIM()去除全部空格
Space()产生空格
AT( )计算字符出现的位置编号
取子窜
LIFT(X,2)左边长算起取2个

vfp函数大全(VFPfunctionDaquan)

vfp函数大全(VFPfunctionDaquan)

vfp函数大全(VFP function Daquan)Visual foxpro数据库函数Adatabases () 将所有打开数据库的名称和路径放到内存变量数组中Adbobjects () 把当前数据库中的命名连接名、关系名、表名或sql 视图名放到一个内存变量数组中Afields () 把当前表的结构信息存放在一个数组中, 并且返回表的字段数返回当前表或指定工作区衰的别名 (alias)Asessions () 创建一个已存在的数据工作期id数组Ataginfo () 创建一个包含索引和键表达式的名字、数量和类型信息的数组Aused () 将一个数据工作期中的表别名和工作区存入内存变量数组确定当前记录指针是否在表头 BOF ()判断索引是否为候选索引 (candidate)根据指定的索引位置编号 (CDX), 返回打开的复合索引 (CDX) 文件名称Cpdbp () 返回一个打开表所使用的代码页Createoffline () 由已存在的视图创建一个游离视图Cursorgetprop () 返回visualfoxpro表或临时表的当前属性设置Cursorsetprop () 指定visualfoxpro表或临时表的属性设置Cursortoxml () 转换visualfoxpro临时表为xml文本从磁盘上的表或远程数据源中直接返回字段值 Curval ()返回当前数据库的名称和路径 (DBC)返回指定工作区中打开的表名 (DBF), 或根据表别名返回表名Dbsetprop () 给当前数据库或当前数据库中的字段、命名连接、表或视图设置一个属性返回一个表明当前记录是否标有删除标记的逻辑值 (deleted)是否用descending关键字创建了一个索引标识 (Descending)Dropoffline () 放弃对游离视图的所有修改, 并把游离视图放回到数据库中确定记录指针位置是否超出当前表或指定表中的最后一个记录 EOF ()Fcount () 返回衰中的字段数目根据编号返回表中的字段名 (FIELD)返回setfilter命令中指定的表筛选表达式 (Filter)Fldlist () 对于setmelds命令指定的字段列表, 返回其中的字段和计算结果字段表达式尝试锁定当前表或指定表 flock ()For 返回一个己打开的单项索引文件或索引标识的索引筛选表达式()如果continue、find、locate或seek命令执行成功 found (), 函数的返回值为 "真"(以字节为单位, 返回指定字段或文件的大小 fsize)Getfldstate () 返回一个数值, 标明表或临时表中的字段是否已被编辑, 或是否有追加的记录, 或者记录的删除状态是否已更改Getnextmodified () 返回一个记录号, 对应于缓冲表或临时表中下一个被修改的记录返回当前或指定表文件的表头所占的字节数 (header)(IDXCOLLATE) sequence returns the index or index mark(INDBC) if the specified database object in the current database, returns true (.T.)(INDEXSEEK) in search of a record first appeared in an indexed table(ISEXCLUSIVE) to determine whether a table or database is openin exclusive mode(ISFLOCKED) return to the locked table(ISREADONLY) to determine whether the table open in read-only mode(ISRLOCKED) locked return records(KEY) index keyword expression returns the index mark or index file(KEYMATCH) search a keyword index in the index or index file(LOOKUP) the search field value with the specified expression, the first record in the tableLUPDATE () returns a date table last updatedMDX (.CDX) according to the composite index file number specified index return open nameMEMLINES () returns the number of rows in the memo fieldMLINE () returns the specified row in the memo field in string formNDX () returns for the current table or an index table to open the specified file name (JDX)ORDER () returns the current table or the specified table masterindex file or logo(PRIMARY) check index, if the main index, it returns "true" (.T.)RECCOUNT () returns the specified number or record in the tableRECNO () returns the current table or specify the current record number in the tableRECSIZE () returns the size for the record in the table (width)(REFRESH) refresh the data in the SQL view can be updated inRELATION () returns the expression specified for a given open workspace in the table(SEEK) in an indexed table in the search for the first time the position of a record(SELECT) the maximum number returned number or use the current workspace workspace(SETFLDSTATE) for a table or a temporary table in the field or record the specified field state value or delete state value(SQLCANCEL) request to cancel an executing SQL statements(SQLCOLUMNS) to specify the data source table column name and information on each column is stored in a temporary table in VisualFoxPro(SQLCOMMIT) submitted a transaction(SQLCONNECT) to establish a connection to the data source(SQLDISCONNECT) to terminate the connection with the data source(SQLEXEC) will be sent to a SQL statement in the source data processing(SQLGETPROP) returns an active connection the current settings or default settings(SQLMORERESULTS) if there is more than one set of results, will be another set of results copied to a temporary table in VisualFoxPro(SQLPREPARE) in the use of SQLEXEC () to perform remote data before operation, you can use this function to make the remote data ready for the command to execute(SQLROLLBACK) cancel any changes made during the current transaction(SQLSETPROP) specify a set of active connections(SQLSTRINGCONNECT) connection using a connection string and a data source(SQLTABLES) the data source table name stored in the temporarytable in VisualFoxProSYS (14) index expressionSYS (21) control index numberSYS (22) to control the name or index nameSYS (2011) returns the current workspace or record locking table locking stateSYS (2012) returns the memo field block size tableSYS (2021) screening indexSYS (2029) and returns the value corresponding to the table typeSYS (3054) Rushmore - grade optimizationTAG (.CDX) name returns the number of composite index file open, or return to the open.IDX index file nameTAGCOUNT (return) composite index file (.CDX) logo and open index file (.IDX) numberTAGNO (return) composite index file (.CDX) identification and open index (.IDX) index file(TARGET) returns a table alias, the table is specified in the INTO clause SETRELATION command relationship goals(UNIQUE) is used to test whether the only way to establish the index(UPDATED) for testing in recent READ commands, whether the data has been modified(USED) to determine whether the specified workspace opens a tableXMLTOCURSOR (XML) convert text to VisualFoxPro cursor or table----------------------------------------------Visual FoxPro date and time functions(CTOD) the character expressions into expressions date.(CDOW) returns a value from a given week date or date time expression.(CMONTH) the name of the month returns a date or a date time expressions.(CTOD) the character expressions into expressions date.CTOT () returns a date time value from a character expression.(DATE) returned by the date of the current system operating system controls, or create a compatible with the 2000 date value.(DATETIME) to date and time value returns the current date and time, or create a 2000 compatible date time value.(DAY) to return to a given date or numeric expression date and time expressions are the first few days.(DMY) a character expression from a date or date and time expression returns a "day month year" format (for example, 31 May 1995). Not abbreviated month name.(DTOC) returned by the date or the date and time expression character date.DTOS (string) returns yyyymmdd date format from the specified date or date and time in the expression.(DTOT) the return date time value from the date.(GOMONTH) for a given date or date and time expressions expressions, before or after the date of the month returns the specified number.(HOUR) return date and time expressions part hours.MDY () returns the specified date or date and time expressions to "month day year" format, which is abbreviated month name.(MINUTE) some minutes to return to date and time in the expression of type.MONTH () returns the date or date and time expressions in thevalue.QUARTER () returns a date or date and time expressions in quarter value.(SEC) part second to return to date and time in the expression of type.(SECONDS) in seconds since midnight after the return time.SYS (1) returns the current system date to date number string.SYS (2) returned since the start of the midnight time, in seconds.SYS (10) (Julian) the date will be converted into a string.SYS (11) the date format date expressions or string converted to date (Julian).(TIME) for 24 hours, the 8 string (hours: Minutes: seconds) returns the current system date and time format.(TTOC) returns a character value from the date and time expressions.TTOD () returns a date value from the date and time.WEEK () returns a value representative of the year the first few weeks from the date or date and time expressions in expression.YEAR () returns the year from the date specified in the.Visual FoxPro character function(ALLTRIM). Delete the specified character expression spaces before and afterASC () returns the leftmost characters in a character expression value of ANSIAT (return) first appeared in another character expression or memo field of a character expression or memo field locationAT_C (return) first appeared in another character expression or memo field of a character expression or memo field locationATC (return) first appeared in another character expression or memo field of a character expression or memo field locationATCC (return) first appeared in another character expression or memo field of a character expression or memo field location(ADDBS) if necessary, add a backslash to a path expressionATCLINE () returns the line number first appeared in another character expression or memo field a character expression or memo field.ATLINE () returns the line number first appeared in another character expression or memo field a character expression ormemo field.(BETWEEN) to determine the value of an expression is in between the other two expressions of the same data type valueCHR (ANSI) according to the numerical code specified the corresponding character(CHRTRAN) will replace the first character in the expression and the second expression character matching character for the corresponding character in the third expression(CHRTRANC) will replace the first character in the expression and the second expression character matching character for the corresponding character in the third expression(CPCONVERT) the character, character expression or memo field conversion to other code page(CHRSAW) to determine whether a character appears in the keyboard buffer(CHRTRAN) in a character expression, to replace the second match the expression character for the corresponding character in the third expression(CHRTRANC) will replace the first character in the expression and the second expression character matching character for the corresponding character in the third expressionDIFFERENCE () returns an integer from 0 to 4, indicatingrelative phonetic difference between expressions of two characters(EMPTY) determines whether the expression is null(GErWORDCOUNr) count a few words in(GETWORDNUM) returns a specified word from a string(INLIST) to determine whether an expression and a set of expressions in a match. '(ISALPHA) to determine the leftmost character expression whether a character is a letter(ISBLANK) to determine whether the expression of null values(ISDIGIT) determine the character expression to the left of a character is digital (0 to 9)(ISLEADBYTE) if the first byte character expression of the first character is a byte, returns true (.T.)(ISLOWER) determine the character expression the leftmost character is lowercase letters(ISMOUSE) to determine whether the computer with mouse(ISNULL) to determine whether the NULL value calculation results(ISUPPER) to determine the first character character expression is uppercase (A ~ z)(LEFT), a character from the leftmost character expression returns a specified number of characters(LEPTC) from the beginning of a character expression of a character on the left returns a specified number of charactersLEN () returns the number of characters in a character expressionLENC () returns the number of characters in the expression to the word(LIKE) to determine whether a character expression is matched with another character expression(LIKEC) to determine whether a character expression is matched with another character expression(LOWER) returns a character expression specified in lowercase letters(LTRIM) a leading space delete character specified, and then return the resulting expression(OCCURS) the number of returns in another character in the expression of a character expression(OEMTOANSI) for a character in the string expression isconverted into the corresponding ANSI character set(PADL), PADR (), PADC () by an expression that returns a character, and from the left, right or from both sides with spaces or characters to fill to the specified length of the string(PROPER) returns a string from a character expression, each string in uppercase first letterRAT (return) first appeared in another character expression or memo field within a character expression or memo field position, from the rightmost character.(RATC) returns a character expression in another character expression or memo field last appeared in the line, from the last line.(RATLINE) line number back to a character expression or memo field in another character expression or memo field appears at the end of the last line, from the start counting.(REPUCATE) returns a string, the string is the specified character expression after repeated a specified number of times(RIGHT) from the beginning of the right string returns a specified number of charactersRIGHTC () returns the right from a specified number of characters in a string(RTRIM) delete a character expression following space after return result stringSOUNDEX (voice) returns a character expression specified representation(SPACE) returns a string consisting of the specified number of spacesSTR () returns the specified numeric expression corresponding to the character(STRCONV) the character expression into another formSTREXTRACT (two) returns a string delimiter between(STRTRAN) in the first character expression or memo field search, second character expressions or memo field, and third character expression - type or memo field replace each occurrence of the second character expressions or memo field(STUFF) returns a string,This string is obtained by the number specified by another character expression to replace the existing character expression of the characters(STUFFC) returns a string, the string is the number specified by another character expression to replace the existing character expression in character, the(SUBSTR) returns a string from a given character expression or memo field(SUBSTRC) returns a string from a given character expression or memo fieldSYS (15) to replace the characters in a stringSYS (20) German text conversion(TEXTMERGE) provide an evaluation on the expression.TRIM () returns the specified character expression after delete all suffix spaces(TXTWIDTH) according to the average width of the character font return character expression length(TYPE) calculation of character expression and returns its contents, data typeUPPER () returns uppercase character expression specified----------------------------------------------Visual FoxPro numerical functionABS (absolute value) returns the specified numeric expressionACOS () returns the arccosine specified numerical value of the expression(ASIN) anyway returns a numeric expression string value radianATAN () returns the arctangent numerical value curve(ATN2) the value of the specified value returned anyway, no limit quadrant return value(BINTOC) the integer represented by binary character.BITAND (two) returns the numeric values in the AND operation by the results(BITCLEAR) refers to a clear positioning numerical numeric (this bit set to 0), and returns the result value(BITLSHIFr) returns a numeric numerical result after moving to the left to the positionBrrNOT () returns a value of type NOT according to the numerical calculation resultsBITOR (two) returns the numeric OR operation according to the numerical results(BITRSHIFF) returns a numeric value to move right after positioning results(BITSET) will be a set value of a numeric 1 and returns the result(BITTEST) to determine the value of a numeric finger positioning is 1BITXOR (two) returns the numeric numerical XOR bitwise resultsCEILING () returns the smallest integer greater than or equal to the specified numeric expressionCOS () returns the numeric expression of Yu Xianzhi(CTOmN) will be converted to an integer type representation of binary characters(DTOR) radians(EVALUATE) to calculate the value of the expression character and returns the result(EVL) a non null value from the two expressions to returnEXP () returns the value of eAx, where x is a numeric expression of a given(FLOOR) on the numerical expression of the given value, returns the largest integer less than or equal to it.FV () returns the future value of a financial investment(INT) a numerical calculation of the value of the expression, and returns the integer part(LOG) the natural logarithm returns a numeric expression (base C)(LOGl0) the common logarithm returns a numeric expression (base 10).(MAX) on the expressions, and returns the expression with maximum value(MIN) to calculate a set of expressions, and returns with the minimum value of the expression(MOD) to remove another numeric expression with a numeric expression that returns the remainder(MTON) a numeric value returned by a currency.(NORMALIZE) to provide users with a character expression can be converted to VisualFoxPro and compared the format function return value(NTOM) returned by a numeric expression containing four decimal currency value(NVL) returns a non null value from two.(PAYMENT) the number of each payment return fixed interest loan repayPI (n) returns a numeric constant(PV) the present value of an investment return(RAND) returns a random number between 0 and 1.ROUND (return) rounded to the specified numeric expression of decimal digits(RTOD) the degree of curvature into(SIGN) when the specified numeric expression value is positive, negative or 0, respectively, 1 -1 or 0 returnSIN () returns a value of the sine angle.SQRT () returns the square root of the specified numeric expressionSYS (2007) returns a character expression check sum valueTAN () returns the value of the tangent angle(VAL) a character expression consists of digits return numeric values----------------------------------------------FTP://********************.net find the help9.chm file in the FTPThis is a function of vfp9.0 command manual contains all command function vfp.You can also join the QQ group VFP heaven:Nineteen million thirty-nine thousand one hundred andthirty-nineNineteen million six hundred and forty-four thousand six hundred and ninety-twoTwenty million one hundred and forty-nine thousand eight hundred and ninety-threeTwenty-one million seven hundred and nine thousand six hundred and twentyThe inside of the master can meet all your questions。

VFP_常用函数

VFP_常用函数
• 由〈起始位置〉指定的字符前面。如果〈字符表达式2〉值是空串,那么 〈字符表达式1〉中 • 由〈起始位置〉和〈长度〉指明的子串被删去。
– 例如:
• • • • STORE 'GOOD BYE!' TO X1 STORE 'MORNING' TO X2 ? STUFF(X1,6,3,X2),STUFF(X1,1,4,X2) GOOD MORNING! MORNING BYE!
– 例如:
• • ? DATE(),TIME(),DATETIME() 08/25/03 16:59:05 08/25/03 04:59:05PM
14.3 日期和时间函数
• 2.求年份、月份和天数函数
– 格式:YEAR(〈日期表达式〉|〈日期时间表达式〉)
• • MONTH(〈日期表达式〉|〈日期时间表达式〉) DAY(〈日期表达式〉|〈日期时间表达式〉)
• 日期时间型,但所有表达式的类型必须相同。
– 例如:
• ? MAX(‘8’,‘100’),MAX(‘8’,‘100’)Байду номын сангаасMIN(‘工作’,‘学 习’,‘休息’) • 100 8 工作
14.2 字符函数
• 字符函数是指自变量一般是字符型数据的函数。 • 1.求字符串长度函数
–格式:LEN(〈字符表达式〉) –功能:返回指定字符表达式值的长度,即所包含的 字符个数。函数值为数值型。 –例如:
• 字符表达式1〉值的首字符在〈字符表达式2〉值中的位置;若不是子串, 则返回0。
– 说明:ATC()与AT()功能类似,但在子串比较时不区分字母大小写。
• 第三个自变量〈数值表达式〉用于表明要在〈字符表达式2〉值中搜索 〈字符表达式1〉值的 • 第几次出现,其默认值是1。

VFP函数

VFP函数
VFP常用函数使用说明
函数
• 函数是一个预先编制好的计算模块,可 在 VFP 的任何地方被调用
1、数值运算函数
• VFP常用函数使用说明 • 1、数值运算函数 ① Abs(x) 求绝对值 Abs(-5.76) 5.76 ② SQRT(x) 求平方根 SQRT(9)3 ③ INT(x) 取整数 INT(3.14)3 ④ ROUND(x) 四舍五入 ROUND(3.14159,4) 3.1416 ?ROUND(345.6799,3) 345.680 ?ROUND(345.6799,0) 346 ?ROUND(345.6799, -2 ) 300 ⑤ Rand(x) 返回一个0-1之间的随机数
12
13
• LIKE (字符表达式 1, 字符表达式 2 )函数 比较字符表达式 1 是否与 字符表达式 2 相匹配,是则返 回逻辑真,否则返回逻辑 假。 说明: 字符表达式 1 中可以包含通配符 * 和?, * 可以 与任何数目 的字符相匹配,?则只能与单个字符相匹 配。注:一个汉字占两个字符
如: x= ” 计算机软件 ” y= ” 计算机 ” ?LIKE(y,x) .f. ?LIKE(X,Y) .f. ?LIKE( “ 计算 * ” ,y) .t. ?LIKE( “ 计算 * ” ,x) .t. ?LIKE( “ 计算 ? ” ,y) .f. ?LIKE( “ 计算 ? ” ,x) .f. ?LIKE( “ 计算 ?? ” ,y) .t. ?LIKE("计算??????" ,x)
2、字符中操作函数
⑧ ⑨ • ⑩ 11 RIGHT(S,N)从字符串S右边取N个字符 S=„12345‟RIGHT(S,3)345 SPACE(N)生成N个空格 "合计"+SPACE(2)+"123” 合计123 TRIM(S)消除字符串尾部空格 • TRIM(“姓名 ”) 姓名 ALLTRI(S)消除字符串中所有空格 • ALLTRIM("李 丽")李丽 STUFF(S1,N1,N2,S2)用字符串S2替换S1中第N1个字符起的N2 个字符 • STUFF("NOW",2,1,"E")NEW & 宏替换 • P=“G2”USE &P USE G2

VFP常用函数

VFP常用函数

347 X="学生.DBF" USE EVALUATE (‘X’) &&相当于执行了 USE 学生.DBF 命 令 A="9*5" ?EVALUATE("A") &&变量为字符型 9*5 ?EVALUATE(A) &相当于执行了 ? EVALUATE("9*5")命令 45 X="学生.DBF" USE(X) &&相当于执行了 USE 学生.DBF 命令
L
N
N C L L
? FILE(“学生 DBF”) T NUM=10 ?IIF(NUM>9,STR(NUM,2),STR(NUM,1)) 10
=MESSAGEBOX(“杭州”)
L
L
FOUND( )
IF EMPTY(THIS.DISPLAYVALUE) RETURN .T. ENDIF USE 学生 LOCATE FOR YEAR(出生年月)<=1971 DO WHILE FOUND( ) ?姓名,出生年月 CONTINUE ENDDO I=INKEY(0) ?I &&如按下回车键,则 I 的值为 13(即回车键的 ASCII 码值)
349
DELETED()
RECCOUNT()
RECNO() FILE(<字符表达式>) IIF(<逻辑表达式>, < 表达式 1>,<表达式 2>)
MESSAGEBOX(< 提 示文本>[, <数值表达 式> [, <标题文本>]]) EMPTY( )
若当前记录已作 删除标记,该函数 返 回 .T. , 否 则 返 回.F 返回表文件记录 总数(包括已作删 除标记的记录) 返回指定表中当 前记录号 测试指定的文件 是否存在 在<逻辑表达式> 的值为.T.时,返回 <表达式 1>的值; 为.F.时返回<表达 式 2>的值 显示一个用户自 定义对话框 确定表达式是否 为空值 如果 CONTINUE、 FIND 、 LOCATE 或 SEEK 命 令 执 行,函数的返回值 为“真”(.T.) 返回一个编号,该 编号对应于键盘 缓冲区中第一个 鼠标单击或按键 操作

vfp常用函数

vfp常用函数

一.数值函数:1、绝对值函数ABS(数值表达式)返回数值表达式的绝对值,返回数据类型:数值型;2、取整函数INT(数值表达式)返回数值表达式的整数部分,返回数据类型:数值型;3、符号函数SIGN(数值表达式)测试表达式的值,若为正数,返回1,若为负数,返回-1,若为0,返回0,返回数据类型:数值型;4、取最小整数函数CEILING(数值表达式)返回大于或等于表达式的值的最小整数,返回数据类型:数值型;5、取最大整数函数FLOOR(数值表达式)返回小于或等于表达式的值的最小整数,返回数据类型:数值型;6、四舍五入函数ROUND(数值表达式,有效位数)对数值表达式按照有效位数进行四舍五入,返回数据类型:数值型;7、求余函数MOD(数值表达式1,数值表达式2)返回表达式1除以表达式2的余数,同号直接求余,若异号,求余后加上表达式2的值,返回数据类型:数值型8、平方根函数SQRT(数值表达式)返回数值表达式的平方根,返回数据类型:数值型9、自然对数函数LOG(数值表达式)返回数值表达式的自然对数,返回数据类型:数值型10、圆周率函数PI( )返回圆周率的值,返回数据类型:数值型二、日期和时间函数1、日期函数DATE()返回当前系统日期,返回默认格式“mm/dd/yy”,返回的数据类型:日期型;2、求年份函数YEAR(日期表达式|日期时间表达式)返回指定日期的年份,返回的数据类型:数值;3、求月份函数MONTH(日期表达式|日期时间表达式)返回指定日期的月份,返回的数据类型:数值;4、求日函数DAY(日期表达式|日期时间表达式)返回指定日期的日的数值,返回的数据类型:数值;5、系统时间函数TIME()返回当前系统时间,返回的默认格式“hh:mm:ss”,返回数据类型:字符型;6、系统日期时间函数DATETIME()返回当前系统日期和时间,返回的数据类型日期时间型三、字符函数1、生成空格函数SPACE(数值表达式)返回一个空格组成的字符串,空格的个数有数值表达式来决定,返回数据类型:字符型2、删除前导空格函数LTRIM(字符表达式)返回指定字符串删除前导空格后的字符串,返回数据类型:字符型。

VF中常用的函数

VF中常用的函数

1、CREATE作用:建立一个新的表。

格式:CREATE [<文件>|?](注意,命令字符可取前面四个字符,后面可省略不写2、MODIFY STRUCTURE作用:显示表文件结构,并允许修改此表的结构。

格式:MODIFY STRUCTURE说明:只有在用USE命令打开表文件以后,才能显示或修改表文件的结构。

3、APPEND作用:在当前表的尾部(无论表中有无记录)追加记录(在当前表指当前正使用的表)。

格式:APPEND [BLANK4、INSERT作用:在表文件中间插入一个新记录。

格式:INSERT [BEFORE] [BLANK]说明:INSERT 在当前记录后插入一记录;5、BROWSE作用:主要用于打开浏览窗口,查阅表文件并同时进行修改。

格式:BROWSE6、USE作用:打开和关闭表文件。

格式:USE [<文件名>]USE说明:前一个命令用来打开<文件名>指定的表文件,该表如有备注型字段,则同时打开相应7、LIST和DISPLAY作用:显示表(.dbf)的内容、结构或状态。

格式:LIST|DISPLAY [OFF] [<范围>] [FIELDS] <表达式表> [WHILE <条件>] [FOR <条>] [TO PRINT|TO FILE <文件>]LIST|DISPLAY STRUCTURE TO PRINT|TO FILE <文件>]LIST|DISPLAY STATUS [TO PRINT|TO FILE <文件>]说明:命令带OFF参数表示不显示记录号,范围指定对哪些记录进行操作,范围包括:RECORD n8、记录的定位作用:用记录指针(POINTER)定位记录。

格式:GO[TO] RECORD n|TOP|BOTTOMnSKIP [+|-]说明:第一个命令又叫绝对定位,其中,RECORD n定位到n号记录,TOP定位到第1个记录,BOTTOM定位到最后一个记录。

VF常用函数

VF常用函数

常用函数ABS():返回一个数值表达式的绝对值。

语法:ABS(数值表达式)返回值:数据型示例 ?ABS(5),ABS(-5) &&返回结果均为:5ALLTRIM():去掉字符型表达式开头和结尾的空格。

TRIM():去掉字符型表达式结尾的空格。

语法:ALLTRIM(字符表达式) 返回值:字符型cString=” Visual FoxPro ”?ALLTRIM(cString) &&返回结果为”Visual FoxPro”?TRIM(cstring) &&返回结果为” Visual FoxPro”ASC():返回字符串左边第一个字符的ASCII码值。

语法:ASC(字符表达式)返回值:数值型?ASC('abcdef') &&返回结果为:97AT():返回字符串1在字符串2中首次出现的位置。

语法:AT(cSearchExpression, cExpressionSearched [, nOccurrence])cSearchExpression:字符串1;cExpressionSearched:字符串2;nOccurrence:指定出现的次数(第一次,第二次)返回值:数值型STORE 'Now is the time for all good men' TO gcStringSTORE 'is the' TO gcFindStringCLEAR &&清空屏屏幕内容? AT(gcFindString,gcString) && 显示5STORE 'IS' TO gcFindString? AT(gcFindString,gcString) && 显示0ATC():返回字符串1在字符串2中首次出现的位置。

字母不分大小写。

其他同AT()?ATC(gcFindString,gcString) &&显示5BETWEEN():返回一个表达式的值是否在两个给定的值之间。

VFP的常用函数及常用命令

VFP的常用函数及常用命令

八、记录的替换 REPLACE <字段名1> WITH <表达示1> [, <字段名2> WITH <表达示2>] [范围][条件] 九、记录浏览 LIST|DISPLAY [FIELDS <字段名表>] [范围] [FOR <条件 >] [WHILE <条件>] [OFF] [TO PRINT] 注:LIST的默认范围为ALL,而DISPLAY为当前记录 DISPLAY ALL与LIST功能基本相同,区别在于DISPLAY ALL会自动分屏显示。 十、打开数据库 USE <数据库名>:单独的USE表示关闭数据库。
3、删除索引 删除索引文件:与删除普通文件相似(先关闭后删除) DELETE FILE 文件名 删除索引标识 DELETE TAG ALL|<索引标识1>[, <索引标识 2>]… 4、索引的更新 已打开的索引文件会自动更新 但如未确定主控索引,则要用REINDEX重新更新。
查询
顺序查询 索引查(字符表达式):字符串长度; AT (字符表达式1,字符表达式2,[ 数值表达式]): 字符1在字符2中第N次出现的位置; ALLTRIM (字符表达式):删除前后空格; SPACE (数值表达式):返回N个空格; UPPER (字符表达式):小写字母转换成大写字母; LOWER (字符表达式):大写字母转换成小写字母; VAL (字符表达式):字符串转换成数值; STR (数值表达式):数值转换成字符串; CHR (数值表达式):从ASC码返回字符串; ASC (字符表达式):返回字符的ASC码;
3、FOR子句 满足条件的记录 4、WHILE子句 不满足条件时停止 5、FIELDS子句 指定字段 6、OFF子字句 不显示记录号 7、TO PRINT 子句 输出到打印机

VFP常用函数大全

VFP常用函数大全

Visual Foxpro 常用函数数值函数:1.绝对值和符号函数格式:ABS(<数值表达式>)SIGN(<数值表达式>)例如:ABS(-5)=5,ABS(4)=4,SIGN(8)=1,SIGN(-3)=-1,SIGN(0)=02.求平方根表达式格式:SQRT(<数值表达式>)例如:SQRT(16)=4,它与开二分之一次方等同。

3.圆周率函数格式:PI()4.求整数函数格式:INT(<数值表达式>)返回数值表达式的整数部分CEILING(<数值表达式>)返回大于或等于表达式的最小整数FLOOR(<数值表达式>)返回小于或等于表达式的最大整数例如:INT(5.8)=5.8,INT(-7.8)=-7,CEILING(6.4)=7,CEILING(-5.9)=-5FLOOR(9.9)=95.四舍五入函数格式:ROUND(<数值表达式1>,<数值表达式2>)功能:返回制定表达式在制定位置四舍五入的结果例如:ROUND(345.345,2)=345.35,ROUND(345.345,1)=345.3,ROUND(345.345,0)=345,ROUND(345.345,-1)=3506.求余函数格式:MOD(<数值表达式1>,<数值表达式2>)例如:MOD(10,3)=1 MOD(10,-3)=-2 MOD(-10,3)=2 MOD(-10,-3)=-1求余数的规律:1.首先按照两数的绝对值求余2.表达式1的绝对值大于表达式2的绝对值,则余数为表达式1的值3.余数取表达式1的正负号4.若两数异好号,余数在加上表达式2的值为最终的结果7. 求最大值和最小值函数MAX(数值表达式列表)MIN (数值表达式列表)例如:MAX(2,3,5)=5 MAX(‘2’,’12’,’05’)=2MAX(‘汽车’,’飞机’,’轮船’)字符串比较的规律:字符串比较首先比较第一个字母,如果有结果那就不用在进行比较了。

vfp表常用函数

vfp表常用函数

vfp表常⽤函数基本操作:1、新建数据库命令:CREATE <⽂件名>2、打开数据库命令:USE <⽂件名>3、浏览数据库命令:BROWSE4、查找记录命令:LOCATE 例:Loca all for 性别=’⼥’Loca all for ⼯资>160.00 .AND. ⼯资<180.00常和继续查找命令CONTINUE连⽤。

FIND 例:find <字符串>/使⽤前需要先排序。

SEEK 例:seek <表达式>表达式是字符串时,必须⽤“”引起来。

如seek “卫明”5、增加库记录命令:APPEND &&增加记录命令APPEND BLANK &&增加⼀条空记录APPEND FROM <⽂件名> [FOR<表达式>] &&从⼀个⽂件复制记录到现⾏数据库中6、插⼊记录命令INSERT格式:insert [blank] [before]use <⽂件名>go 5insert before7、库记录的删除DELETE格式:DELETE [<范围>] [FOR<表达式>] [WHILE<表达式>]功能:给符合条件的库记录加上删除标记。

例:delete all for 性别=’⼥’PACK格式:PACK功能;把打开的数据库⽂件中作过删除标记的记录真正删除掉。

ZAP格式:ZAP功能;从打开的数据库⽂件中删除所有记录8、恢复命令RECALL格式;RECALL [<范围>] [FOR<表达式>] [WHILE<表达式>]功能;恢复打开的数据库⽂件中带有删除标记的记录9、库记录的修改EDIT格式:EDIT [<范围>] [FIELDS<字段名表>] [FOR<表达式>] [WHILE<表达式>]CHANGE格式:CHANGE [<范围>] [FIELDS<字段名>] [FOR<表达式>] [WHILE<表达式>]BROWSE格式:BROWSE [FIELDS<字段名>] [LOCK<表达式>] [FREEZE<字段名>]10、替换命令REPLACE格式;REPLACE [<范围>] <字段名1> WITH <表达式1> [,<字段名2> WITH<表达式2>…] [FOR<表达式>] [WHILE<表达式>]功能:⽤来替换打开的数据库⽂件中指定字段的数据。

vfp常用函数

vfp常用函数

一.数值函数:1、绝对值函数ABS(数值表达式)返回数值表达式的绝对值,返回数据类型:数值型;2、取整函数INT(数值表达式)返回数值表达式的整数部分,返回数据类型:数值型;3、符号函数SIGN(数值表达式)测试表达式的值,若为正数,返回1,若为负数,返回-1,若为0,返回0,返回数据类型:数值型;4、取最小整数函数CEILING(数值表达式)返回大于或等于表达式的值的最小整数,返回数据类型:数值型;5、取最大整数函数FLOOR(数值表达式)返回小于或等于表达式的值的最小整数,返回数据类型:数值型;6、四舍五入函数ROUND(数值表达式,有效位数)对数值表达式按照有效位数进行四舍五入,返回数据类型:数值型;7、求余函数MOD(数值表达式1,数值表达式2)返回表达式1除以表达式2的余数,同号直接求余,若异号,求余后加上表达式2的值,返回数据类型:数值型8、平方根函数SQRT(数值表达式)返回数值表达式的平方根,返回数据类型:数值型9、自然对数函数LOG(数值表达式)返回数值表达式的自然对数,返回数据类型:数值型10、圆周率函数PI( )返回圆周率的值,返回数据类型:数值型二、日期和时间函数1、日期函数DATE()返回当前系统日期,返回默认格式“mm/dd/yy”,返回的数据类型:日期型;2、求年份函数YEAR(日期表达式|日期时间表达式)返回指定日期的年份,返回的数据类型:数值;3、求月份函数MONTH(日期表达式|日期时间表达式)返回指定日期的月份,返回的数据类型:数值;4、求日函数DAY(日期表达式|日期时间表达式)返回指定日期的日的数值,返回的数据类型:数值;5、系统时间函数TIME()返回当前系统时间,返回的默认格式“hh:mm:ss”,返回数据类型:字符型;6、系统日期时间函数DATETIME()返回当前系统日期和时间,返回的数据类型日期时间型三、字符函数1、生成空格函数SPACE(数值表达式)返回一个空格组成的字符串,空格的个数有数值表达式来决定,返回数据类型:字符型2、删除前导空格函数LTRIM(字符表达式)返回指定字符串删除前导空格后的字符串,返回数据类型:字符型。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
例:x=\"Foxpro\"
?Asc(x),Asc(lower(x))
70 102
9.ASCⅡ码值转字符函数:
格式:chr(数值表达式)
功能:把数值转成相应的ASCⅡ码字符,返回值为字符型
例:?chr(70)+chr(111)+chr(111+9)
Fox
四.日期函数:
1.系统日期函数:
格式:date()
2005年11月14日
5.时间转字符函数:
格式:ttoc(时间)
功能:将时间转为时间字符串
6.字符转时间函数:
格式:ctot(c)
功能:将时间字符串转化为时间
7.字符串替换函数:
格式:stuff(<字符表达式1>,<起始位置>,<字符个数>,<字符表达式2>)
功能:从指定位置开始,用<表达式2>的值去替换<表达式1>中指定个数字符.若<字符个数>为零,直接插入;若<表达式2>为空字符串,则删除<表达式1>中指定个数的字符.
例:X=\"祝大家新年好!\"
?stuff(X,7,4,\"春节\")
祝大家春节好
?stuff(X,11,0,\"春节\")
祝大家新年春节好
?stuff(x,7,4,\" \")
祝大家好
8.字符转ASCⅡ码函数:
格式:Asc(<字符表达式>)
功能:把<字符表达式>左边第一个字符转成相应的ASCⅡ码值
(3).day(日期表达式):从日期表达式中返回一个用数字表示的日数.
例:测试系统日期
rq=date()
?year(rq),month(rq),day(rq)
2005 11 14
3.系统时间函数:
格式:time()
功能:得到当前时间字符串
例:?time()
20:32:26
4.系统日期时间函数:
格式:datetime()
&&变量tui用于接收messagebox函数的返回值,弹出的窗口如图1
?tui
&&变量tui值取决于运行时用户点了哪个按钮,如果点了\"是\",返回6,如果点了\"否\",返回7,见表2
说明:实际应用中,我们常在系统菜单或在表单的\"退出\"按钮中添加如下代码:
tui=messagebox(\"您确实要退出系统吗?\",4+64,\"提示信息\")
if tui=6 &&如果此条件成立,说明用户点了\"是\"按钮,执行quit命令,安全退出
quit
endif
3 Tuesday
五.测试函数:
1.测试文件尾函数:
格式:eof([n])
说明:
(1).n指定被测工作区号,其范围为1~32767
(2).该函数用于测试指定工作区中的表的记录指针是否指向文件尾,是则返回真值;否则返回假值;省略可选项指当前工作区.
例:测试文件记录指针是否指向文件尾
use职工档案
go bottom
功能:得到当前日期时间
例:?datetime()
2005.11.14 08:35:12 PM
5.星期函数:
格式:dow(日期表达式)
cdow(日期表达式)
功能:dow用数字表示星期,1表示星期日,7为星期六;cdow用英文表示星期
例:?date()
2005.11.15
?dow(date()),cdow(date())
例:
?mod(10,3)
1
6.求指数、对数函数:
格式:
exp(数值表达式)
log(数值表达式)
功能:
(1).exp()计算自然数e?表达式的值为指数的幂
(2).log()计算表达式值的自然对数,返回lnx的值.
例:
x=1
y=exp(x)
?exp(x),log(x)
2.72 1
三.转换函数:
1.数值转数字字符串函数:
VPF常用函数
一.字符及字符串处理函数:字符及字符串处理函数的处理对象均为字符型数据,但其返回值类型各异.
1.取子串函数:
格式:substr(c,n1,n2)
功能:取字符串C第n1个字符起的n2个字符.返回值类型是字符型.
例:取姓名字符串中的姓.
store \"王小风\" to xm
?substr(xm,1,2)
结果为:王
2.删除空格函数:以下3个函数可以删除字符串中的多余空格,3个函数的返回值均为字符型.
trim(字符串):删除字符串的尾部空格
alltrim(字符串):删除字符串的前后空格
ltrim(字符串):删除字符串的前面的空格
例:去掉第一个字符串的尾空格后与第二个字符串连接
store \"abcd \" to x
5.取右子串函数:
格式:right(c,n)
功能:取字符串c右边的n个字符
例:a=\"我是中国人\"
?right(a,4)
国人
?left(a,2)

6.empty(c):用于测试字符串C是否为空格.
7.求子串位置函数:
格式:At(字符串1,字符串2)
功能:返回字符串1在字符串2的位置
例:?At(\"教授\",\"副教授\")
?eof()
.F.
skip
?eof()
.T.
2.测试文件头函数:
格式:bof([n])
说明:
(1).n指定被测工作区号,其范围为1~32767
(2).用于测试指定工作区中的表的记录指针是否指向文件头,是则返回真值;否则返回假值;省略可选项指当前工作区.
例:测试记录指针是否指向文件头
use职工档案
go top
use职工档案
locate for姓名=\"小刚\"
?found()
.t.
display
7.文件测试函数:
格式:file(字符表达式)
功能:测试字符表达式指定的文件是否存在
例:?file(\"e:\\myvfp\\职工档案.dbf\")
.t.
8.数据类型测试函数:
格式:type(字符表达式)
功能:测试表达式的数据类型,返回大写字母:N(数值)、C(字符)、L(逻辑)、D(日期)、M(备注)
3\"是\",\"否\"和\"取消\"按钮
4\"是\"和\"否\"按钮
5\"重试\"和\"取消\"按钮
16stop图标
32?图标
48!图标
64i图标
0默认第1个按钮
256默认第2个按钮
512默认第3个按钮
(2).返回值见表2:
返回值按钮
1确定
2取消
3终止
4重试
5忽略
6是
7否
例:分析messagebox(\"您确实要退出系统吗?\",4+64,\"提示信息\")会弹出什么样的窗口.
功能:求指定字符串的长度
例:a=\"中国人\"
?len(a)
6
二.数学运算函数:
1.取整函数:
格式:int(数值)
功能:取指定数值的整数部分.
例:取整并显示结果
?int(25.69)
25
2.四舍五入函数:
格式:round(数值表达式,小数位数)
功能:根据给出的四舍五入小数位数,对数值表达式的计算结果做四舍五入处理
store \"efg\" to y
?trim(x)+y
abcdefg
3.空格函数:
格式:space(n)
说明:该函数的功能是产生指定个数的空格字符串(n用于指定空格个数).
例:定义一个变量dh,其初值为8个空格
store space(8) to dh
4.取左子串函数:
格式:left(c,n)
功能:取字符串C左边n个字符.
例:将日期型数据转化为字符型日期数据并显示汉字日期.
set century on &&开启世纪前缀,即日期中年份用4位表示
set date ansi
rq={^2005.11.14}
rq=dtoc(rq)
?substr(rq,1,4)+\"年\"+substr(rq,6,2)+\"月\"+substr(rq,9,2)+\"日\"
例:为\"工资情况\"表中每个人加100元工资
gz=\"工资\"
use工资情况
replace all &gz with &gz+100
2.条件函数:
格式:iif(表达式,表达式1,表达式2)
功能:若表达式值为真,则返回表达式1的值;否则返回表达式2的值;函数返回值类型与表达式1或表达式2类型一致
a=3
?alias()
工资情况&&打开表时,不指定别名,表名即为别名
select zgda &&通过别名选择工作区
?select()
1
11.表文件名函数:
相关文档
最新文档