




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Visual FoxPro定义了13种字段类型和7种数据类型 字符型字段和字符型数据 数值型、浮动型、双精度型和整型字段与数值型数据 货币型字段和货币型数据 日期型字段和日期型数据 日期时间型字段和日期时间型数据 逻辑型字段和逻辑型数据 备注型字段 通用型字段和通用型数据 二进制字符型字段和二进制备注型字段,VFP数据类型,Use student in 1 List Use course in 2 List Select 2 list,工作区:表打开后才能操作,实际上打开表 就是将其从磁盘调入到内存的某一个工作区。,每个工作区只允许打开一个表,在同一工作区打开另一个表时,以前打开的表就会自动关
2、闭。,在任一时刻,用户只能对其中的一个工作区进行操作。正在被用户操作的工作区称为 当前工作区。,工作区彼此之间是相互独立的,即在未建立表间关系的情况下,对当前工作区中表的任何操作,均不会影响其它工作区中打开的表。,VFP 多工作区方式,VFP提供32767个工作区,编号为132767。 标识:相应数字;前10个可用别名 AJ 标记 同一个表可在不同区打开 初始状态当前工作区为区,VFP 多工作区方式,工作区除了使用数字编号外,用户也可自行指定工作区的别名; 命令格式:USE ALIAS 示例:USE 学生表 ALIAS Student 命令格式:USE IN | 在指定的工作区打开表,但不改变
3、当前工作区,要改 变工作区仍需使用SELECT命令。,工作区的选择互访,VFP 多工作区方式,工作区的选择互访 命令:SELECT nWorkArea|cTableAlias,功能:选定某个工作区,用于打开一个表。 示例:SELECT A SELECT 2,选定的工作区称为当前工作区,VFP默认1号工作区为当前工作区。 使用函数SELECT()可返回当前工作区的区号。 SELECT 0,表示选定当前尚未使用的最小号工作区。 使用其它工作区中字段:.或- 示例:DISP 学号,姓名,班级,B.课程号,B.成绩,VFP 多工作区方式,对于一个打开的表文件来说,在某一时刻只能处理一条记录,这条记录叫
4、做当前记录。 VFP在每一个表中都定义了一个指针,随着我们对表的操作,记录指针在不断地移动。 刚刚打开表时,记录指针指向第一条记录。,记录指针,VFP 记录指针,VFP对表内记录是逐条进行操作的。 最上面的记录是首记录,记为TOP; 最下面的记录是尾记录,记为BOTTOM。 在第一个记录之前有一个文件起始标识, 称为Begin of File(BOF)。 在最后一个记录的后面有一个文件结束标识, 称为End of File(EOF)。,尾记录,首记录,VFP 记录指针,记录指针,与记录指针有关的函数,测试文件尾函数:eof(nWorkArea|cTableAlias) 测试文件头函数:bof(
5、nWorkArea|cTableAlias) 测试当前记录号函数:recno(nWorkArea|cTableAlias),eg: ?eof(); eg: ?bof() eg: ?recno(),尾记录,首记录,TOP,BOTTOM,VFP 记录指针,记录指针,指针的定位与移动,Go record nRecordNumber|top|bottom Skip nRecords IN nWorkArea|cTableAlias Locate Scope For LExpression1 While LExpression2 Continue (配合Locate使用;for子句while子句的差异)
6、,Use studentGo top ?bof() Skip 1 ?bof() Go bottom ?eof() Skip ?eof(),Use student; List; Locate for .not. Ssex ?recno(); Continue; ?recno(),VFP 记录指针,CommandKeyScope eExpressionList For LExpression1 While LExpression2 说明: CommandKey命令关键字:表示进行什么操作,如use,select Scope 范围子句: Record n 表中第n条记录 Next n 从表中当前记录
7、起向下共n条 Rest 从表中当前记录起到末记录止 All 表中全部记录,VFP命令一般格式,eExpressionList 表达式表: 由逗号分隔的表达式构成,通常由表中字段名构成, 表示只对所列字段进行操作。 For LExpression1 条件子句 While LExpression2 条件子句 表示对逻辑表达式取真值的记录进行规定的操作 区别优先级,VFP命令一般格式,For和While选择项,在默认范围选择项条件下主要有以下两点不同: FOR子句是从首记录开始判断逻辑表达式是取真值还是取假值的,而While子句则从当前记录起判断条件是否成立。 For于句对逻辑表达式取真值的所有记录
8、进行规定操作,不管这些记录是呈连续排列或是间断排列;但对While子句则是从当前记录开始,只要遇到其逻辑表达式取假值的记录就立即停止操作,不管其后是否还有满足条件的记录。 For和While子句在某些命令中,既可单独使用,也可以同时。在同时选用的情况下,While子句优先级高于For子句。,Use student List for ssex use,Use student List while ssex use,Use student List for ssex while ssex use,VFP命令一般格式,数据容器 保存数据的常量、变量、数组、字段、对象叫数据的存贮容器,简称数据容器。
9、常用的数据容器有: 常量、变量、数组、字段、对象属性,Visual FoxPro 数据容器,一、常量 类型:数值型、字符型、逻辑型、日期型日期时间型 赋值:define x 18释放:#undefine x 二、变量 类型:字段变量(多值)、内存变量系统内存变量(list memo) 赋值:store to (单个),Visual FoxPro 数据容器,eg: store 5 to a,b,c 等价于 a=5;b=5;c=5,Visual FoxPro 数据容器,二、变量 显示:list memory like 或display memory like 释放:release MemVarli
10、st 或 release all like 保存:save all like to (扩展名.mem) 恢复:restore from 作用域:局部(local ); 私有( private ); 公共(public ) 系统规定:字段名优先;M-内存变量名或M.内存变量名,eg:save to file1; save all to file2; save all like a? to file3,eg: ?sno eg: ?bof() eg: ?recno(),Visual FoxPro基础常用函数,四、测试函数 测试表文件记录数函数:reccount(nWorkArea|cTableAli
11、as) 测试字段名函数:field(nFieldNumber,nWorkArea|cTableAlias) 测试字段数函数:fcount( nWorkArea|cTableAlias) 测试查找记录是否成功函数:found( nWorkArea|cTableAlias) 常用查找命令:Find; Seek; locate,eg: ?reccount() eg: ?field(5) eg: ?fcount(),Use student Locate for sno=05 ?found(),sname,Visual FoxPro基础常用函数,五、其它函数 键值函数:inkey(nScends,cHi
12、deCursor) nScends表示等待按键的秒数,为无限等待 cHideCursor用于指定显示隐藏光标或检查鼠标按键;H,S,M 宏函数:cMemVarName .cExpression cMemVarName字符型内存变量;cExpression字符型表达式 条件函数:IIf( LExpression, eExpression1 , eExpression2) 六、用户自定义函数,eg: ?inkey(10,”H”),Accept 表名: to bm Use &biaoming List,Use student Locate for sno=05 ?iif(found(),sname,
13、查无此人),Visual FoxPro基础常用命令,一、打开库文件 Open database FileName|?exclusive|shared 二、打开表文件 Use TableName|?IN nWorkArea|cTableAliasAgain Index IndexFileList Order nIndexNumber|IDXFilename|TAG TagName OF CDXFileName Ascending|Descenging Alias cTableAliasExclusiveSharedNoUpdate,Open database XJGL.dbc,Use sc in
14、 2 order tag in_grade alias xuanke,Visual FoxPro基础常用命令,三、从键盘向表添加记录、插入记录 Append Blank IN nWorkArea|cTableAlias Insertbefore|blank 四、文件复制命令 Copy To FileName Fields FieldList Scope For LExpression1 While LExpression2,Use student append,Use student Copy to studentM for ssex Use studentM list,Visual FoxP
15、ro基础常用命令,五、记录指针定位 Go record nRecordNumber|top|bottom Skip nRecords IN nWorkArea|cTableAlias Locate Scope For LExpression1 While LExpression2 Continue (配合Locate使用;for子句while子句的差异),Use studentGo top ?bof() Skip 1 ?bof() Go bottom ?eof() Skip ?eof(),Use student List Locate for .not. Ssex ?recno() Conti
16、nue ?recno(),Visual FoxPro基础常用命令,六、表数据输出 List |Display Fields FieldListScopeFor LExpression1While LExpression2 七、记录删除恢复 逻辑删除:Delete ScopeFor LExpression1While LExpression2 恢复命令:Recall ScopeFor LExpression1While LExpression2 物理删除:Pack MemoDbf 清表命令:Zap,Use student List fields sno,sname for ssex,Use st
17、udent Display List Use,无任何选项,Visual FoxPro基础常用命令,八、表的修改编辑 记录替换: Replace FieldName1 with eExpression1addtive FieldName2 with eExpression2addtive ScopeFor LExpression1While LExpression2 浏览编辑: Browse Fields FieldList For LExpression1 Freeze FieldNameLock nNumberOfFields 编辑修改: Change Fields FieldList Sc
18、opeFor LExpression1 Freeze FieldName ,Use student Replace All Sage with Sage+1 for ssex,Visual FoxPro基础常用命令,九、表数据排序 Sort To TableName on FieldName1 /A /D /C , FieldName2 /A /D /CAscending|Descending Scope For LExpression1While LExpression2Fields FieldNameList 十、索引查找 索引文件类型:一般索引文件(.Idx)&复合索引文件(.Cdx)
19、建立索引文件: Index on eExpression to IDXFileName|TAG TagName OF CDXFileName For LExpression1Compact Ascending|DescengingUniqueAdditive,Use student Sort to Student_age on sage/d Use student_age list,Use student Index on sdept tag bm,Use student Index on sage to nl,Visual FoxPro基础常用命令,十、索引查找 打开索引文件: Use In
20、dex IndexFileList Order nIndexNumber|IDXFilename|TAG TagName OF CDXFileName Ascending|Descenging Set Index to IndexFileList Order nIndexNumber|IDXFilename|TAG TagName OF CDXFileName Ascending|DescengingAddtive 关闭索引文件: Close Index 指定主索引文件和主标记: Set Order to nIndexNumber|IDXFilename|TAG TagName OF CDXF
21、ileName 重建索引文件:ReIndex Compact,Visual FoxPro基础常用命令,十、索引查找 索引查找: Find cExpression 说明:使用前打开索引; 不必用引号; 变量使用宏函数 Seek cExpression Order nIndexNumber|IDXFilename|TAG TagName OF CDXFileName Ascending|Descenging 说明:功能更强;可指定索引;用引号;变量使用宏函数,use student index on Sdept tag dept set order to dept list find B disp
22、lay seek “B” display,Visual FoxPro基础常用命令,十一、求和、计数汇总 求和: Sum eExpressionList Scope For LExpression1 While LExpression2 To MemVarNameList 计数: Count Scope For LExpression1 While LExpression2 To MemVarName,Use student Sum sage to total_age for ssex ?total_age,Use student Count for .not. ssex to female_n
23、um ? female_num,Visual FoxPro基础常用命令,十一、求和、计数汇总 求平均数: Average eExpressionList Scope For LExpression1 While LExpression2To MemVarNameList 分类汇总: Total to TableName On FieldName Fields FieldNamelist Scope For LExpression1 While LExpression2,Use student Average sage to age_aver for ssex ? age_aver,Use sc
24、 Set order to in_sno Total on sno to grage_aver fields grade Use grage_aver list,Visual FoxPro基础常用命令,十一、程序的建立&执行(.prg) 程序建立: Modify command FileName 设置当前工作目录: Set default to cPath 程序执行: Do FileName 十二、程序的建立&执行(.prg) 输出语句:?|? eExpression1AT nColumn ,Expression2 等待语句:Wait cMessageTextTo memVarName Win
25、dow AT nRow,nColumn TimeOut nSeconds 清屏语句:Clear 输入语句:Accept | Input cPromptText To MemVarName,Input 请输入圆半径to r,Visual FoxPro基础常用命令,十三、事件程序结构 顺序结构:,Clear Use student Accept 请输入学号: to xh Locate for sno=xh Disp Use,Visual FoxPro基础常用命令,十三、事件程序结构 选择结构: 格式: If Lexpression Command1 Else Command2 EndIf,Clea
26、r Use student Accept 请输入学号: to xh Locate for sno=xh If .not. Eof() disp Else ?查无此人 endif Use,Visual FoxPro基础常用命令,十三、事件程序结构 选择结构:,Do case case LExpression1 Command1 case LExpression2 Command2 case LExpressionN CommandN Otherwise CommandN+1 EndCase,Do case case grade60 grade=grade+10 case grade70 grad
27、e=grade+5 case grade80 grade=grade+2 Otherwise grade=grade+1 EndCase,Visual FoxPro基础常用命令,十三、事件程序结构 循环结构:,Do while Lexpression Commands Loop Exit EndDO,clear Use sc Do while .not. Eof() Do case case grade60 replace grade with grade+10 case grade70 replace grade with grade+5 case grade80 replace grade with grade+3 Otherwise replace grade with grade+1 EndCase skip Enddo Use,Visual FoxPro基础常用命令,十三、事件程序结构 循环结构:,For MemVarName= nInitialValue To nFinalValue Step nIncrement Commands Loop Exit Endfor|Next,Scan Scope For LExpres
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 创新办公家具设计在企业培训中的应用案例
- 历史智慧在当代社会的价值体现
- 中国农产品电商发展现状及趋势分析
- 全球化背景下的银行市场开拓策略
- 全球气候变化与环境保护
- 中国传统工艺在高端制造中的应用
- 房屋装修工程施工安全措施
- 旅游行业高风险活动管理与监测计划
- 企业信息化的绩效评估与优化
- 基于深度学习的智能教育平台建设计划
- 2025山西晋城市城区城市建设投资经营限公司招聘15人高频重点提升(共500题)附带答案详解
- 危险废物收集、贮存扩建项目环境风险评价专项报告
- 2024年广东省普通高等学校招收中等职业学校毕业生统一模拟考试语文题真题(解析版)
- JJF(陕) 041-2020 宽带采集回放系统校准规范
- 应用英语(陕西交通职业技术学院)知到智慧树答案
- 保安员资格考试复习题库及答案(800题)
- 员工岗位培训范本
- 消防员职业技能鉴定中级技能题库
- 《公路建设项目文件管理规程》
- 非物质文化遗产展示基地项目可行性研究报告
- 日军宣传标语大全
评论
0/150
提交评论