Visual FoxPro定義了13種字段類型和7種數(shù)據(jù)類型_第1頁
Visual FoxPro定義了13種字段類型和7種數(shù)據(jù)類型_第2頁
Visual FoxPro定義了13種字段類型和7種數(shù)據(jù)類型_第3頁
Visual FoxPro定義了13種字段類型和7種數(shù)據(jù)類型_第4頁
Visual FoxPro定義了13種字段類型和7種數(shù)據(jù)類型_第5頁
已閱讀5頁,還剩32頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、Visual FoxPro定義了13種字段類型和7種數(shù)據(jù)類型 字符型字段和字符型數(shù)據(jù) 數(shù)值型、浮動(dòng)型、雙精度型和整型字段與數(shù)值型數(shù)據(jù) 貨幣型字段和貨幣型數(shù)據(jù) 日期型字段和日期型數(shù)據(jù) 日期時(shí)間型字段和日期時(shí)間型數(shù)據(jù) 邏輯型字段和邏輯型數(shù)據(jù) 備注型字段 通用型字段和通用型數(shù)據(jù) 二進(jìn)制字符型字段和二進(jìn)制備注型字段,VFP數(shù)據(jù)類型,Use student in 1 List Use course in 2 List Select 2 list,工作區(qū):表打開后才能操作,實(shí)際上打開表 就是將其從磁盤調(diào)入到內(nèi)存的某一個(gè)工作區(qū)。,每個(gè)工作區(qū)只允許打開一個(gè)表,在同一工作區(qū)打開另一個(gè)表時(shí),以前打開的表就會(huì)自動(dòng)關(guān)

2、閉。,在任一時(shí)刻,用戶只能對其中的一個(gè)工作區(qū)進(jìn)行操作。正在被用戶操作的工作區(qū)稱為 當(dāng)前工作區(qū)。,工作區(qū)彼此之間是相互獨(dú)立的,即在未建立表間關(guān)系的情況下,對當(dāng)前工作區(qū)中表的任何操作,均不會(huì)影響其它工作區(qū)中打開的表。,VFP 多工作區(qū)方式,VFP提供32767個(gè)工作區(qū),編號(hào)為132767。 標(biāo)識(shí):相應(yīng)數(shù)字;前10個(gè)可用別名 AJ 標(biāo)記 同一個(gè)表可在不同區(qū)打開 初始狀態(tài)當(dāng)前工作區(qū)為區(qū),VFP 多工作區(qū)方式,工作區(qū)除了使用數(shù)字編號(hào)外,用戶也可自行指定工作區(qū)的別名; 命令格式:USE ALIAS 示例:USE 學(xué)生表 ALIAS Student 命令格式:USE IN | 在指定的工作區(qū)打開表,但不改變

3、當(dāng)前工作區(qū),要改 變工作區(qū)仍需使用SELECT命令。,工作區(qū)的選擇互訪,VFP 多工作區(qū)方式,工作區(qū)的選擇互訪 命令:SELECT nWorkArea|cTableAlias,功能:選定某個(gè)工作區(qū),用于打開一個(gè)表。 示例:SELECT A SELECT 2,選定的工作區(qū)稱為當(dāng)前工作區(qū),VFP默認(rèn)1號(hào)工作區(qū)為當(dāng)前工作區(qū)。 使用函數(shù)SELECT()可返回當(dāng)前工作區(qū)的區(qū)號(hào)。 SELECT 0,表示選定當(dāng)前尚未使用的最小號(hào)工作區(qū)。 使用其它工作區(qū)中字段:.或- 示例:DISP 學(xué)號(hào),姓名,班級(jí),B.課程號(hào),B.成績,VFP 多工作區(qū)方式,對于一個(gè)打開的表文件來說,在某一時(shí)刻只能處理一條記錄,這條記錄叫

4、做當(dāng)前記錄。 VFP在每一個(gè)表中都定義了一個(gè)指針,隨著我們對表的操作,記錄指針在不斷地移動(dòng)。 剛剛打開表時(shí),記錄指針指向第一條記錄。,記錄指針,VFP 記錄指針,VFP對表內(nèi)記錄是逐條進(jìn)行操作的。 最上面的記錄是首記錄,記為TOP; 最下面的記錄是尾記錄,記為BOTTOM。 在第一個(gè)記錄之前有一個(gè)文件起始標(biāo)識(shí), 稱為Begin of File(BOF)。 在最后一個(gè)記錄的后面有一個(gè)文件結(jié)束標(biāo)識(shí), 稱為End of File(EOF)。,尾記錄,首記錄,VFP 記錄指針,記錄指針,與記錄指針有關(guān)的函數(shù),測試文件尾函數(shù):eof(nWorkArea|cTableAlias) 測試文件頭函數(shù):bof(

5、nWorkArea|cTableAlias) 測試當(dāng)前記錄號(hào)函數(shù):recno(nWorkArea|cTableAlias),eg: ?eof(); eg: ?bof() eg: ?recno(),尾記錄,首記錄,TOP,BOTTOM,VFP 記錄指針,記錄指針,指針的定位與移動(dòng),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命令關(guān)鍵字:表示進(jìn)行什么操作,如use,select Scope 范圍子句: Record n 表中第n條記錄 Next n 從表中當(dāng)前記錄

7、起向下共n條 Rest 從表中當(dāng)前記錄起到末記錄止 All 表中全部記錄,VFP命令一般格式,eExpressionList 表達(dá)式表: 由逗號(hào)分隔的表達(dá)式構(gòu)成,通常由表中字段名構(gòu)成, 表示只對所列字段進(jìn)行操作。 For LExpression1 條件子句 While LExpression2 條件子句 表示對邏輯表達(dá)式取真值的記錄進(jìn)行規(guī)定的操作 區(qū)別優(yōu)先級(jí),VFP命令一般格式,For和While選擇項(xiàng),在默認(rèn)范圍選擇項(xiàng)條件下主要有以下兩點(diǎn)不同: FOR子句是從首記錄開始判斷邏輯表達(dá)式是取真值還是取假值的,而While子句則從當(dāng)前記錄起判斷條件是否成立。 For于句對邏輯表達(dá)式取真值的所有記錄

8、進(jìn)行規(guī)定操作,不管這些記錄是呈連續(xù)排列或是間斷排列;但對While子句則是從當(dāng)前記錄開始,只要遇到其邏輯表達(dá)式取假值的記錄就立即停止操作,不管其后是否還有滿足條件的記錄。 For和While子句在某些命令中,既可單獨(dú)使用,也可以同時(shí)。在同時(shí)選用的情況下,While子句優(yōu)先級(jí)高于For子句。,Use student List for ssex use,Use student List while ssex use,Use student List for ssex while ssex use,VFP命令一般格式,數(shù)據(jù)容器 保存數(shù)據(jù)的常量、變量、數(shù)組、字段、對象叫數(shù)據(jù)的存貯容器,簡稱數(shù)據(jù)容器。

9、常用的數(shù)據(jù)容器有: 常量、變量、數(shù)組、字段、對象屬性,Visual FoxPro 數(shù)據(jù)容器,一、常量 類型:數(shù)值型、字符型、邏輯型、日期型日期時(shí)間型 賦值:define x 18釋放:#undefine x 二、變量 類型:字段變量(多值)、內(nèi)存變量系統(tǒng)內(nèi)存變量(list memo) 賦值:store to (單個(gè)),Visual FoxPro 數(shù)據(jù)容器,eg: store 5 to a,b,c 等價(jià)于 a=5;b=5;c=5,Visual FoxPro 數(shù)據(jù)容器,二、變量 顯示:list memory like 或display memory like 釋放:release MemVarli

10、st 或 release all like 保存:save all like to (擴(kuò)展名.mem) 恢復(fù):restore from 作用域:局部(local ); 私有( private ); 公共(public ) 系統(tǒng)規(guī)定:字段名優(yōu)先;M-內(nèi)存變量名或M.內(nèi)存變量名,eg:save to file1; save all to file2; save all like a? to file3,eg: ?sno eg: ?bof() eg: ?recno(),Visual FoxPro基礎(chǔ)常用函數(shù),四、測試函數(shù) 測試表文件記錄數(shù)函數(shù):reccount(nWorkArea|cTableAli

11、as) 測試字段名函數(shù):field(nFieldNumber,nWorkArea|cTableAlias) 測試字段數(shù)函數(shù):fcount( nWorkArea|cTableAlias) 測試查找記錄是否成功函數(shù):found( nWorkArea|cTableAlias) 常用查找命令:Find; Seek; locate,eg: ?reccount() eg: ?field(5) eg: ?fcount(),Use student Locate for sno=05 ?found(),sname,Visual FoxPro基礎(chǔ)常用函數(shù),五、其它函數(shù) 鍵值函數(shù):inkey(nScends,cHi

12、deCursor) nScends表示等待按鍵的秒數(shù),為無限等待 cHideCursor用于指定顯示隱藏光標(biāo)或檢查鼠標(biāo)按鍵;H,S,M 宏函數(shù):cMemVarName .cExpression cMemVarName字符型內(nèi)存變量;cExpression字符型表達(dá)式 條件函數(shù):IIf( LExpression, eExpression1 , eExpression2) 六、用戶自定義函數(shù),eg: ?inkey(10,”H”),Accept 表名: to bm Use &biaoming List,Use student Locate for sno=05 ?iif(found(),sname,

13、查無此人),Visual FoxPro基礎(chǔ)常用命令,一、打開庫文件 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基礎(chǔ)常用命令,三、從鍵盤向表添加記錄、插入記錄 Append Blank IN nWorkArea|cTableAlias Insertbefore|blank 四、文件復(fù)制命令 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基礎(chǔ)常用命令,五、記錄指針定位 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基礎(chǔ)常用命令,六、表數(shù)據(jù)輸出 List |Display Fields FieldListScopeFor LExpression1While LExpression2 七、記錄刪除恢復(fù) 邏輯刪除:Delete ScopeFor LExpression1While LExpression2 恢復(fù)命令:Recall ScopeFor LExpression1While LExpression2 物理刪除:Pack MemoDbf 清表命令:Zap,Use student List fields sno,sname for ssex,Use st

17、udent Display List Use,無任何選項(xiàng),Visual FoxPro基礎(chǔ)常用命令,八、表的修改編輯 記錄替換: 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基礎(chǔ)常用命令,九、表數(shù)據(jù)排序 Sort To TableName on FieldName1 /A /D /C , FieldName2 /A /D /CAscending|Descending Scope For LExpression1While LExpression2Fields FieldNameList 十、索引查找 索引文件類型:一般索引文件(.Idx)&復(fù)合索引文件(.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基礎(chǔ)常用命令,十、索引查找 打開索引文件: 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 關(guān)閉索引文件: Close Index 指定主索引文件和主標(biāo)記: Set Order to nIndexNumber|IDXFilename|TAG TagName OF CDXF

21、ileName 重建索引文件:ReIndex Compact,Visual FoxPro基礎(chǔ)常用命令,十、索引查找 索引查找: Find cExpression 說明:使用前打開索引; 不必用引號(hào); 變量使用宏函數(shù) Seek cExpression Order nIndexNumber|IDXFilename|TAG TagName OF CDXFileName Ascending|Descenging 說明:功能更強(qiáng);可指定索引;用引號(hào);變量使用宏函數(shù),use student index on Sdept tag dept set order to dept list find B disp

22、lay seek “B” display,Visual FoxPro基礎(chǔ)常用命令,十一、求和、計(jì)數(shù)匯總 求和: Sum eExpressionList Scope For LExpression1 While LExpression2 To MemVarNameList 計(jì)數(shù): 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基礎(chǔ)常用命令,十一、求和、計(jì)數(shù)匯總 求平均數(shù): 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基礎(chǔ)常用命令,十一、程序的建立&執(zhí)行(.prg) 程序建立: Modify command FileName 設(shè)置當(dāng)前工作目錄: Set default to cPath 程序執(zhí)行: Do FileName 十二、程序的建立&執(zhí)行(.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基礎(chǔ)常用命令,十三、事件程序結(jié)構(gòu) 順序結(jié)構(gòu):,Clear Use student Accept 請輸入學(xué)號(hào): to xh Locate for sno=xh Disp Use,Visual FoxPro基礎(chǔ)常用命令,十三、事件程序結(jié)構(gòu) 選擇結(jié)構(gòu): 格式: If Lexpression Command1 Else Command2 EndIf,Clea

26、r Use student Accept 請輸入學(xué)號(hào): to xh Locate for sno=xh If .not. Eof() disp Else ?查無此人 endif Use,Visual FoxPro基礎(chǔ)常用命令,十三、事件程序結(jié)構(gòu) 選擇結(jié)構(gòu):,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基礎(chǔ)常用命令,十三、事件程序結(jié)構(gòu) 循環(huán)結(jié)構(gòu):,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基礎(chǔ)常用命令,十三、事件程序結(jié)構(gòu) 循環(huán)結(jié)構(gòu):,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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論